I need help in this java prob
- Prompt user for new height of the triangle after the result was printed out
- User can terminate the program by entering number, 0 and below
/* Output
Enter height of triangle: 3
1 2 3
1 2
1
Enter height of triangle: 2
1 2
1
Enter height of triangle: -1
*/
Attached is my incomplete program
Code Java:import java.util.*; public class Triangle { public static void main (String[]args) { Scanner sc = new Scanner(System.in); System.out.print("Enter the height of triangle: "); int height = sc.nextInt(); for (int num=height; num>0; num--) { for (int dispNum=0; dispNum<num; dispNum++) { System.out.print(dispNum+1 +" "); } System.out.print("\n"); } } }
