DonanımHaber Mini sürüm 2 Ocak 2026 tarihi itibariyle kullanımdan kalkacaktır. Bunun yerine daha hızlı bir deneyim için DH Android veya DH iOS uygulamalarını kullanabilirsiniz.
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");
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
devamına ne yazmam gerektiğini bulamıyorum.