Alright this is kinda urgent because the program is due in a few hours.
Here's the instructions:
Program Description: Write a program that accepts a number of rows between 0 and 9. Produce a multiplication triangle of n rows. For each row contains entries up to it's row size (i.e row 3 will have the values 1X3, 2X3, 3X3, row 4 will have the values 1X4,2X4,3X4,4X4).
Sample Output:
Enter # of rows 6
1 2 3 4 5 6
1
2 4
3 6 9
4 8 12 16
5 10 15 20 25
6 12 18 24 30 36
Enter # of rows 2
1 2
1
2 4
Enter # of rows 7
1 2 3 4 5 6 7
1
2 4
3 6 9
4 8 12 16
5 10 15 20 25
6 12 18 24 30 36
7 14 21 28 35 42 49
This is what I have:
import java.util.Scanner;
public class Prog166g
{
public static void main(String[] args)
{
//Set up keyboard
Scanner keyboard = new Scanner(System.in);
//Variables
int input;
//Input
System.out.print("Enter # of rows: ");
input = keyboard.nextInt();
//Loop to get first row
for (int counter = 1; counter <= input; counter++)
{
System.out.print("\t" + counter);
}
System.out.println("");
//Loop to get everything else
for (int count = 1; count <= input; count++)
{
System.out.println("\t" + count);
}
}
}
And this is what I'm getting (using 2 as sample input):
Enter # of rows: 2
1 2
1
2
Can you please help me?? I've tried everything and I just can't get anything to work.