This is my program so far, it wants to print an upside down right triangle until "6 5 4" is printed. I can't seem to get it to 6 5 4 much less stop it
import java.util.Scanner;
public class Lab16C {
private int num;
public static void main(String[ ] args)
{
Lab16C lab = new Lab16C( );
lab.input(); // Read rom the keyboard
lab.output(); // Display output
}
public void input() {
Scanner reader = new Scanner(System.in);
System.out.print("Enter a number: ");
num = reader.nextInt();
}
public void output(){
for(int y = 0 ; y < num ; y++)
{
for(int x = num ; x >= 4; x--)
System.out.print(x + " ");
num = num -1;
System.out.println ();
}
}
}
Aucun commentaire:
Enregistrer un commentaire