. Write a Java program that calculates the multiplication table (up to 10) of the randomly generated number (between 1 and 100), and displays that on the screen.
Hint: Math function and For loop.Â
public class App {
/**
* The start point of the program
*Â
* @param args
*/
public static void main(String[] args) {
for (int i = 1; i <= 10; i++) {
int num = (int) (Math.random() * 101) + 1;
System.out.printf("%d x %d = %d\n", i, num, num * i);
}
}
}
Comments
Leave a comment