Question: Hi, can anyone help me with the following java program: You MUST use a while loop to print numbers 1-100. If the number is divisible
Hi, can anyone help me with the following java program:
You MUST use a while loop to print numbers 1-100. If the number is divisible by 3 print Soda instead of the number. If the number is divisible by 5 print Pop instead of the number. If the number is divisible by 3 AND 5 print *SP*.
Print 10 numbers/words to a line. Display the numbers/words in right-aligned columns. Use printf statements to do this. For example: System.out.printf( "5d", number ); System.out.printf( "5s", "Soda" ); Every time there are ten numbers on a line print a newline to move down to the next line.
Use the command prompt window (terminal) for output.
And this is the sample out put:
1 2 Soda 4 Pop Soda 7 8 Soda Pop 11 Soda 13 14 *SP* 16 17 Soda 19 Pop Soda 22 23 Soda Pop 26 Soda 28 29 *SP* 31 32 Soda 34 Pop Soda 37 38 Soda Pop 41 Soda 43 44 *SP* 46 47 Soda 49 Pop Soda 52 53 Soda Pop 56 Soda 58 59 *SP* 61 62 Soda 64 Pop Soda 67 68 Soda Pop 71 Soda 73 74 *SP* 76 77 Soda 79 Pop Soda 82 83 Soda Pop 86 Soda 88 89 *SP* 91 92 Soda 94 Pop Soda 97 98 Soda Pop Programmed by Your Full Name
I'm confused. Also, this should be using while loop.
Step by Step Solution
There are 3 Steps involved in it
Get step-by-step solutions from verified subject matter experts
