Create a program called TimesTable java. My program would be ConwayTimesTable.ja
ID: 3855194 • Letter: C
Question
Create a program called TimesTable java. My program would be ConwayTimesTable.java and my class name would be Conway Times Table Write a program that contains a nested for loop that prints a multiplication table. The values being multiplied will begin at 1. The user will enter the upper bounds for the factors. The multiplication facts will be displayed as shown in the simple output. Add a blank line between groups of facts as shown in the sample output. Sample output: > run ConwayTimesTable Enter the first factor: Enter the second factor: 1 * 1 = 1 1 * 2 = 2 1 * 3 = 3 1 * 4 = 4 1 * 5 = 5 2 * 1 = 2 2 * 2 = 4 2 * 3 = 6 2 * 4 = 8 2 * 5 = 10 3 * 1 = 3 3 * 2 = 6 3 * 3 = 9 3 * 4 = 12 3 * 5 = 15 > run ConwayTimesTable Enter the first factor: Enter the second factor:Explanation / Answer
TimesTable.java
import java.util.Scanner;
public class TimesTable {
public static void main(String[] args) {
// Declaring variables
int firstfactor, secondfactor;
// Scanner object is used to get the inputs entered by the user
Scanner sc = new Scanner(System.in);
// getting the inputs entered by the user
System.out.print("Enter the first factor :");
firstfactor = sc.nextInt();
System.out.print("Enter the second factor :");
secondfactor = sc.nextInt();
// dispalying the table
for (int i = 1; i <= firstfactor; i++) {
for (int j = 1; j <= secondfactor; j++) {
System.out.println(i + " * " + j + " = " + (i * j));
}
System.out.println();
}
}
}
____________________
Output:
Enter the first factor :3
Enter the second factor :5
1 * 1 = 1
1 * 2 = 2
1 * 3 = 3
1 * 4 = 4
1 * 5 = 5
2 * 1 = 2
2 * 2 = 4
2 * 3 = 6
2 * 4 = 8
2 * 5 = 10
3 * 1 = 3
3 * 2 = 6
3 * 3 = 9
3 * 4 = 12
3 * 5 = 15
__________________
Output#2:
Enter the first factor :5
Enter the second factor :3
1 * 1 = 1
1 * 2 = 2
1 * 3 = 3
2 * 1 = 2
2 * 2 = 4
2 * 3 = 6
3 * 1 = 3
3 * 2 = 6
3 * 3 = 9
4 * 1 = 4
4 * 2 = 8
4 * 3 = 12
5 * 1 = 5
5 * 2 = 10
5 * 3 = 15
_____________Could you rate me well.Plz .Thank You
Related Questions
drjack9650@gmail.com
Navigate
Integrity-first tutoring: explanations and feedback only — we do not complete graded work. Learn more.