Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

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

Step: 1

blur-text-image

Get Instant Access to Expert-Tailored Solutions

See step-by-step solutions with expert insights and AI powered tools for academic success

Step: 2

blur-text-image

Step: 3

blur-text-image

Ace Your Homework with AI

Get the answers you need in no time with our AI-driven, step-by-step assistance

Get Started

Recommended Textbook for

Microsoft Visual Basic 2017 For Windows Web And Database Applications

Authors: Corinne Hoisington

1st Edition

1337102113, 978-1337102117

More Books

Students also viewed these Databases questions

Question

What aspects would it be impossible to capture?

Answered: 1 week ago

Question

Enhance your words with effective presentation aids

Answered: 1 week ago