mardi 3 mars 2015

number pattern program wont add anymore outputs?

I'm supposed to have four patterns in a single program but the program won't output anything past my 2nd for statement. Can someone take a look at this please? Line RIGHT after Pattern C is where it stops outputting.



import java.util.Scanner;

public class Patterns
{
public static void main(String[] args)
{
Scanner input = new Scanner(System.in);

System.out.print("Enter a positive maximum integer value: ");
int max = input.nextInt();

//1st Pattern
System.out.println("\nPattern A: ");

for (int i = 1; i <= max; i++){

for (int j = 1; j <= i; j++){
System.out.print(j + " ");
}
System.out.println();
}

//2nd Pattern
System.out.println("\nPattern B:");

for (int i = -5; i <= max; i++, max--){

for (int j = 1; j <= max; j++){
System.out.print(j + " ");
}
System.out.println();
}

// 3rd pattern and WHERE PROBLEM STARTS!!
System.out.println("\nPattern C:");
for (int i = 0; i < max; i++){

for (int j = i; j < 0; j++){
System.out.print(j + " ");
}
System.out.println();
}
}
}

Aucun commentaire:

Enregistrer un commentaire