Page 1 of 1

in java Rewrite the following program to modularise it into separate methods. public class Test { public static void mai

Posted: Fri Jul 01, 2022 5:37 am
by answerhappygod
in java
Rewrite the following program to modularise it into separatemethods.
public class Test { public static void main(String[] args) { inti, j; int power; for (i = 1; i < 10; i++) {System.out.println("Here is the multiplication table for " + i);for (j = 1; j < 10; j++) { System.out.println(i + " x " + j + "= " + (i * j)); } System.out.println("Here is a table of powers for" + i); j = 0; power = 1; while (j <= 5) { System.out.println(i+ " to the power of " + j + " is " + power); j++; power = power *i; // multiply once more. }System.out.println("-----------------------"); } } }
In particular: What lines would move into different methods?Why?