1. Engineering
  2. Computer Science
  3. import javautilscanner public class theforloop public static void mainstring...

Question: import javautilscanner public class theforloop public static void mainstring...

Question details

import java.util.Scanner;

public class TheForLoop
{
public static void main(String[] args)
{
//initialize Scanner for keyboard entry
Scanner in = new Scanner(System.in);

//initialize StringBuilder for keyboard entry
StringBuilder builder = new StringBuilder();

//initialize variables
int startValue = 1;
int endValue = 10;

//using for loop to create multiplication table
for(int row = startValue; row < endValue; row++)
{
for(int col = startValue; col < endValue; col++)
{
builder.append(String.format("%-4d \n", row * col));
}
}
//display builder converted to string
System.out.print(builder.toString());
}
}

What can I change to make it print a multiplication table to the screen instead of a straight column in java please what am I missing?

Solution by an expert tutor
Blurred Solution
This question has been solved
Subscribe to see this solution