Arama butonu
Bu konudaki kullanıcılar: 1 misafir, 1 mobil kullanıcı
5
Cevap
1397
Tıklama
0
Öne Çıkarma
java right triangle?
B
12 yıl (253 mesaj)
Teğmen
Konu Sahibi

benden istenen bu:

Write a program that prints a right triange out of numbers. After each time a number is printed, the number should be incremented by 1. The program should also print a space character after each number.

Your program should work as follows;

- Get a number from user, which is number of columns

- Check if the user input is valid (it should be greater than 1). If not print an error message "Invalid number of columns"

- If the number is valid, print a right triangle having inputted number of columns and as stated above.

Sample Execution 1:

Enter number of columns: -1

Invalid number of columns

Sample Execution 2:

Enter number of columns: 3

1

2 3

4 5 6

Sample Execution 3:

Enter number of columns: 5

1

2 3

4 5 6

7 8 9 10

11 12 13 14 15


benim şu ana kadar yazdıklarım şunlar
quote:

public static void main(String[] args) {
Scanner tri = new Scanner(System.in);
System.out.print("Enter number of columns: ");
int columns = tri.nextInt();

while(0<=columns);

if(0>=columns);
System.out.print("Invalid number of columns");

else

devamına ne yazmam gerektiğini bulamıyorum.