import java.util.Scanner;
public class Triangles {
public static void main(String[] args) {
Scanner keyboard = new Scanner(System.in);
int pattern;
System.out.println(" - - - Welcome to Bhaswar's Traingle/Diamond Patterns - - - ");
System.out.println("Which pattern do you want to print?");
System.out.println("1) 54321 2) 1 3) 12345 4) 1");
System.out.println(" 4321 12 1234 123");
System.out.println(" 321 123 123 12345");
System.out.println(" 21 1234 12 123");
System.out.println(" 1 12345 1 1");
System.out.print("Enter your choice (5 to quit):");
while ((pattern = keyboard.nextInt()) >= 1 && pattern <= 5)
{
switch (pattern)
{
case 1:
System.out.print("How many rows would you like to print? More than 1 please:");
int r1 = keyboard.nextInt();
for (int i=1; i<=r1; i++)
{
for (int j=r1; j>=i; j--)
{
System.out.print("" +j);}
System.out.print("\n");
}
}
}
}
}
this is all i currently have
with a bit of mucking about i've gotten the numbers for the first triangle to look like:
54321
5432
543
54
5
unfortunately thats not what i'm trying to get
i'm aiming for
54321
4321
321
21
1
any suggestions? i can't figure out how to get the 2nd second line starting from 4 and the 3rd line starting from 3 and so on...