Problem 3- Multiplication Table [25 points Write a program called Multiplication
ID: 3889059 • Letter: P
Question
Problem 3- Multiplication Table [25 points Write a program called MultiplicationTable to produce the multiplication table of 1 to 9 as shown below using two nested for-loops: (Hint - use a printf statement to align the data in the columns.) > java MultiplicationTable 1 23 45 6 7 89 1 12 3 4 5 6 7 8 9 2 2 468 10 12 14 16 18 3 3 6 9 12 15 18 21 24 27 4 48 12 16 20 24 28 32 36 5 5 10 15 20 25 30 35 40 45 6 6 12 18 24 30 36 42 48 54 7 7 14 21 28 35 42 49 56 63 8 8 16 24 32 40 48 56 64 72 9 9 18 27 36 45 54 63 72 81Explanation / Answer
//we will use printf() function Here
import java.util.*;
public class MultiplicationTable
{
public static void main(String args[])
{
int k=1;
System.out.printf(" ");
for(int i=1;i<=9;i++)
{
System.out.printf("%d ",i);
}
System.out.printf(" --------------------------------------- ");
for(int i=1;i<=9;i++)
{
System.out.printf("%d",k);
for(int j=1;j<=9;j++)
{
System.out.printf(" %d",i*j); //using printf() function
}
System.out.printf(" ");
k++;
}
}
}
Related Questions
drjack9650@gmail.com
Navigate
Integrity-first tutoring: explanations and feedback only — we do not complete graded work. Learn more.