Academic Integrity: tutoring, explanations, and feedback — we don’t complete graded work or submit on a student’s behalf.

This program should use two for loops to display a table consisting of four rows

ID: 3581070 • Letter: T

Question

This program should use two for loops to display a table consisting of four rows and two columns. The first column should contain the numbers 10, 12, 14 and 16. The second and subsequent columns should contain the result of multiplying the number in the first column by the numbers 2 through 5. For example the first two rows of the table should look like this:

10 20 30 40 50
12 24 36 48 60

Public Class MainForm
Private Sub displayButton_Click(sender As Object, e As EventArgs) Handles displayButton.Click
Dim Product As Integer
For i As Integer = 10 To 16

tableLabel.Text = tableLabel.Text & ControlChars.NewLine & i.ToString
For j As Integer = 2 To 5
Product = i * j
tableLabel.Text = tableLabel.Text & "" & Product

Next j
Next i

End Sub

Private Sub exitButton_Click(sender As Object, e As EventArgs) Handles exitButton.Click
Me.Close()
End Sub
End Class

Explanation / Answer

Solution for the Problem:-

import java.util.Scanner;
class MainForm
{
   public static void main(String args[])
   {
       int a[][]=new int[10][10];
       int i,j,n,number=2;
       System.out.println("Enter number of Values(columns) ");
       Scanner in=new Scanner(System.in);
       n=in.nextInt();
       for(i=0;i<1;i++)
       {
           for(j=0;j<n;j++)
           {
               a[i][j]=in.nextInt();
           }
       }
       for(i=1;i<5;i++)
       {
           for(j=0;j<n;j++)
           {
               a[i][j]=a[0][j]*number;
           }
           number++;
       }
       System.out.println("The array is ");
       for(i=0;i<5;i++)
       {
           for(j=0;j<n;j++)
           {
               System.out.print(a[i][j]+" ");
           }
           System.out.println(" ");
       }
      
   }
  
}

Sample Output :-

C:Users ajendrajava>javac MainForm.java

C:Users ajendrajava>java MainForm
Enter number of Values(columns)

4
10 12 14 16
The array is

10 12 14 16 // -> User given Values

20 24 28 32 //-> Multiple with 2

30 36 42 48 //->Multiple with 3

40 48 56 64 //-> Multiple with 4

50 60 70 80 //->Multiple with 5

Note :- In your question their is an ambiguous between columns finally by considering example out put the problem was solved in question their are values 10,12,14,16 these values are multiply by 2 through 5 (by considering given example).In above code there is a chance to take the values dynamically and also numbe of values also dynamically.

Thank you!

Hire Me For All Your Tutoring Needs
Integrity-first tutoring: clear explanations, guidance, and feedback.
Drop an Email at
drjack9650@gmail.com
Chat Now And Get Quote