Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

Sprint 00:51 HWSternary.pdf COMP 163 TERNARY PROGRAM Homework 5 Part 1. [0 ps-] Write a program that prints a number in base&rapresenitation Haseuses only the

image text in transcribed
image text in transcribed
Sprint 00:51 HWSternary.pdf COMP 163 TERNARY PROGRAM Homework 5 Part 1. [0 ps-] Write a program that prints a number in base&rapresenitation Haseuses only the digitsQ, 1,2. The flowchart is on the next page Call your program Ternary Java Your program peempts the userforanmput ???ber-then prints the result For example: Nusber The coee of the program is a while loep. Each time through the loop iR adds one more digit to the left of the arwer string The loop algoeithm is rem- remainder efn & it will he , 1, or2 -n/3 uing intager division, it will be a whok namber pu the digit indicated by the remainder onto the left of the answer string The loop continucs until n is acno So for cxample if the inpat were 47 em 2 (remindler of 47/3)pt 2 into the amwer sering it is sow -13 (4773 rem-ocremnder of IS3), put?into the answer sring. itisW" rem-2 (remainder of 53Aptinto the answer string, it is 202 m-1 (remainder o 1/3A put"1 intio the answer string, it is-1202 and you are done If the number is originally Q,just peist Some special emes are If the number is nepative, then make it positive and put" is froat of the answer. Part 2. [30 ps ] Put the alporithm into a GUt It should have a program name, a e feld for the ieput, a label for the output, and a button to make it go Pee arrange the GUI components horiaontalily and put londers around the text ficld and the output label, and some ox space between the componen Numerical planaties Here is how the algorithm works The right-digit is the Is place, the next digit is the 3s place, then the 9s place, 27s place Each is the nest Nggest power of 3 For xample, the number 47 is wrimon 1202 in hase 3, From left to right I in the y place-27 2 in the place 18 0 in the 3' place 2 in the 3" plaxe-2 Total 27+18+247 The mivas sign goes in front as usual so the mumber-100 is writen-1020 00-1x8129 Open With Print

Step by Step Solution

There are 3 Steps involved in it

Step: 1

blur-text-image

Get Instant Access to Expert-Tailored Solutions

See step-by-step solutions with expert insights and AI powered tools for academic success

Step: 2

blur-text-image

Step: 3

blur-text-image

Ace Your Homework with AI

Get the answers you need in no time with our AI-driven, step-by-step assistance

Get Started

Recommended Textbook for

Database Design And SQL For DB2

Authors: James Cooper

1st Edition

1583473572, 978-1583473573

More Books

Students also viewed these Databases questions

Question

Why does sin 2x + cos2x =1 ?

Answered: 1 week ago

Question

What are DNA and RNA and what is the difference between them?

Answered: 1 week ago

Question

Why do living creatures die? Can it be proved that they are reborn?

Answered: 1 week ago

Question

How do Data Types perform data validation?

Answered: 1 week ago

Question

How does Referential Integrity work?

Answered: 1 week ago