import java.util.Scanner;
public class brickgame {
public brickgame() {
}
public static void main (String[] args) {
System.out.println("Choose the operation you want to do?");
Scanner charles = new Scanner(System.in);
String number;
System.out.print("[1] Biography \n[2] Calculator \n[3] Bye \nChoose the number:");
number=charles.nextLine();
if(number.equals("1")) {
Scanner naria = new Scanner(System.in);
String Fname,Age,Address,Birthplace,Birthday,FavoriteF,FavoriteS,FavoriteC,Hobby,STalent;
System.out.println("Please use Underscore Character or _ as your spacebar! ");
System.out.print("Please Enter your Name: ");
Fname = naria.next();
System.out.print("Please Enter your Age: ");
Age = naria.next();
System.out.print("Please Enter your Address: ");
Address = naria.next();
System.out.print("Please Enter your Birthplace: ");
Birthplace = naria.next();
System.out.print("Please Enter your Birthday: ");
Birthday = naria.next();
System.out.print("Please Enter your Favorite Food: ");
FavoriteF = naria.next();
System.out.print("Please Enter your Favorite Subject: ");
FavoriteS = naria.next();
System.out.print("Please Enter your Favorite Color: ");
FavoriteC = naria.next();
System.out.print("Please Enter your Hobby: ");
Hobby = naria.next();
System.out.print("Please Enter your Secret Talent: ");
STalent = naria.next();
System.out.println("Hello "+Fname);
System.out.println("You are "+ Age +" years old");
System.out.println("You lived at "+Address);
System.out.println("You are born in "+ Birthplace);
System.out.println("Your birthday is on "+Birthday);
System.out.println("Your Favorite Food is "+FavoriteF);
System.out.println("Your Favorite Color is "+FavoriteC);
System.out.println("Your Favorite Color is "+FavoriteS);
System.out.println("Your hobby is to "+Hobby);
System.out.println("Your Secret Talent is to "+ STalent);
}
else if(number.equals("2")) {
while (true)
{
Scanner glenn = new Scanner(System.in);
String chosen;
int a,b,ab,e,f;
float d,c,dc;
System.out.println("\n[1] Addition \n[2] Subtraction \n[3] Multiplication \n[4] Division \n[5] Greater Than/Less Than \n[6] Return \nEnter the number you chose:");
chosen=glenn.nextLine();
if(chosen.equals("1")) {
System.out.print("Enter your first number: ");
a=glenn.nextInt();
System.out.print("Enter your second number: ");
b=glenn.nextInt();
ab=a+b;
System.out.print(a + " + " + b + " = " +ab);
}
else if(chosen.equals("2")) {
System.out.print("Enter your first number: ");
a=glenn.nextInt();
System.out.print("Enter your second number: ");
b=glenn.nextInt();
ab=a-b;
System.out.print(a + " - " + b + " = " +ab);
}
else if(chosen.equals("3")) {
System.out.print("Enter your first number: ");
a=glenn.nextInt();
System.out.print("Enter your second number: ");
b=glenn.nextInt();
ab=a*b;
System.out.print(a + " * " + b + " = " +ab);
}
else if(chosen.equals("4")) {
System.out.print("Enter your first number: ");
c=glenn.nextInt();
System.out.print("Enter your second number: ");
d=glenn.nextInt();
dc=c/d;
System.out.print(c + " / " + d + " = " +dc);
}
else if(chosen.equals("5")) {
System.out.print("Enter your first number: ");
e=glenn.nextInt();
System.out.print("Enter your second number: ");
f=glenn.nextInt();
if (e>f){
System.out.print(e + " is greater than "+ f);
}
if(e<f){
System.out.print(e + " is lesser than "+ f);
}
if(e==f){
System.out.print(e + " is same as "+ f);
}
}
if(chosen.equals("6")) {
System.out.println(" \nThank you and Goodbye!");
break;
}
}
}
else System.out.println(" \nThank you and Goodbye!");
}
}
I wanted the break to change to return back to biography and calculator choice, I need help please because Ive been struggling too much now, I dont know what statements do I use to make it work, I only got like a few hours to finish it and Ive been struggling real, real hard for the past 2 hours
It is an easy problem but I am only a programmer for 2 weeks rn thats why I needed help, any help is appreaciated
If you want to implement a way to return to the menu after completing an operation, this is what I would do:
booleanvariable to control the menu loop. You can usetrueto keep the menu running until the user wants to exit.whileloop to keep the menu active.For biography:
For Calculator: