I need help in JAVA! Here are following requirements to completing Menu shapes: Create menu that have 5 options 1. Fille

Business, Finance, Economics, Accounting, Operations Management, Computer Science, Electrical Engineering, Mechanical Engineering, Civil Engineering, Chemical Engineering, Algebra, Precalculus, Statistics and Probabilty, Advanced Math, Physics, Chemistry, Biology, Nursing, Psychology, Certifications, Tests, Prep, and more.
Post Reply
answerhappygod
Site Admin
Posts: 899604
Joined: Mon Aug 02, 2021 8:13 am

I need help in JAVA! Here are following requirements to completing Menu shapes: Create menu that have 5 options 1. Fille

Post by answerhappygod »

I need help in JAVA!
Here are following requirements to completing Menu shapes:
Create menu that have 5 options
1. Filled Triangle
2. Filled Inverted Triangle
3. Square
4. Bow Tie
5.Exit
With the following requirements:
a. case statements for each menu option 1,2,3,4,5
b. User input user to enter the height (the amount of rows) of
your shape or you can ask them to enter the width and height of
your shape.
c. while loop or do/while loop
d. for loop for each shape
e. functions for each shape
HERES WHAT I HAVE SO FAR:
import java.util.Scanner;
import javax.swing.*;
import java.awt.*;
import java.awt.event.*;
import javax.swing.JOptionPane;
import javax.swing.JOptionPane;
public class menulab {
public static void main(String[] args) {
// TODO Auto-generated method stub

System.out.println("+-------------------------------+");
System.out.println("| Lab 5 |");
System.out.println("| Menu Application |");
System.out.println("+-------------------------------+");
System.out.println("");


//Display menu

System.out.println("This program allows you to select multiple
shapes ");
System.out.println("");
System.out.println("1. Filled Triangle ");
System.out.println("2. Filled Inverted Triangle ");
System.out.println("3. Square ");
System.out.println("4. Bow Tie ( extra credit) ");
System.out.println("5. Exit ");
System.out.println("");
String[] optionstochoose = {"Filled Triangle", "Filled Inverted
Triangle", "Square", "Bow Tie", "Exit"};

String shapeoption = (String) JOptionPane.showInputDialog(
null,
"Check the console screen and select from the 5 options ",
"Choose an option",
JOptionPane.QUESTION_MESSAGE,
null,
optionstochoose,
optionstochoose[5]);

System.out.println(" You choose Option: " + shapeoption);


Scanner sc=new Scanner(System.in);
int choice=sc.nextInt();
switch (choice)
{
case 1: // Filled Triangle
System.out.println("Enter the height of the filled triangle between
(2 - 50); ");
int rows=sc.nextInt();
while (rows < 2 || rows > 50)

{
System.out.println("Enter the number of lines between (2 - 50);
");
int numlines=sc.nextInt();
}

int i, j;
for (i = 1; i <= rows; i++);{

for (j = 1; j <= i; j++) {

}
System.out.printf("*");
}
break;

case 2: // Inverted filled triangle
break;

case 3: //Need a different triangle here

for(int i = 1; i <= rows; i++);
{
//For adding the right amount of spaces
int x = 0;
//Prints the first set of asterisks
for(j = i; j > 0; j--);
{
System.out.printf("*");
x+=2;
}
//Prints the spaces
for(int f = 0; f < (rows * 2) - x; f++)
{
System.out.printf("");
}
// Prints the second set
for(int l = i; l > 0; l--)
{
System.out.printf("*");
}
}

break;

case 4:
System.out.printf("Exiting ...");
return;
break;

}



while (choice >= 1 && choice <= 4);
return;


}
}
I need help refining the code. here's a picture of what the bow
tie should look like.
I Need Help In Java Here Are Following Requirements To Completing Menu Shapes Create Menu That Have 5 Options 1 Fille 1
I Need Help In Java Here Are Following Requirements To Completing Menu Shapes Create Menu That Have 5 Options 1 Fille 1 (21.8 KiB) Viewed 56 times
* * * ¥ * * * * * ¥ ¥ * * *
Join a community of subject matter experts. Register for FREE to view solutions, replies, and use search function. Request answer by replying!
Post Reply