Write an application to print out the numbers 10 through 49 in the following manner:
How would you do it? Here is an example of poorly written code:
for ( int i = 10; i < 50; i++) {
switch (i) {
case 19:
case 29:
case 39: System.out.println(" " + i); //move to the
break; //next line
default: System.out.print(" " + i);
}
}
This code is not good because it works only for printing 10 through 49. Try to develop the code so that it can be extended easily to handle any range of values. You can do this coding in two ways: with a nested for statement or with modulo arithmetic. (If you divide a number by 10 and the remainder is 9, then the number is 9, 19, 29, or 39, and so forth.)
We need at least 10 more requests to produce the solution.
0 / 10 have requested this problem solution
The more requests, the faster the answer.