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