Question: In Java, ( Display pyramid upside down ) Write a program that prompts the user to enter an integer from 1 to 1 5 and

In Java, (Display pyramid upside down) Write a program that prompts the user to enter an integer from 1 to 15 and displays a pyramid. My code isn't working and was wondering if someone could fix it:
package chapter5ex3;
import java.util.Scanner;
public class Chapter5Ex3{
public static void main(String[] args){
Scanner input = new Scanner(System.in);
System.out.print("Enter a number between 1-15: ");
int numberOfLines = input.nextInt();
int i;
int j;
int k;
int x;
boolean b = true;
for (int rows =1; rows <= numberOfLines; rows++){
for (i = x; i >0; i--){
for (j = i; j >0; j--){
for (k =0; k <((x - i)) && b; k++){
System.out.print("");
}
if (x >9 && j >8 && b){
for (k =0; k <(x - j); k++){
System.out.print("");
}
}
if (x >9 && j <9 && b){
for (k =0; k < x -9; k++){
System.out.print("");
}
}
System.out.print(j +"");
b = false;
}
for (j =2; j <(i +1); j++){
System.out.print(j +"");
}
System.out.println();
b = true;
}
}
}
}

Step by Step Solution

There are 3 Steps involved in it

1 Expert Approved Answer
Step: 1 Unlock blur-text-image
Question Has Been Solved by an Expert!

Get step-by-step solutions from verified subject matter experts

Step: 2 Unlock
Step: 3 Unlock

Students Have Also Explored These Related Databases Questions!