#who know how to fix my while loop?
16 messages · Page 1 of 1 (latest)
ok so i should remove the first check the value of 1 and remove choice variable
I would suggest that you pick up the input of the user and then use a SWITCH instead of IFs better.
let me fix the loop now
sorry wheres that
what is your objective here? explain the exercise to me
i have a plan thats made let me send lol
creating a menu, jewellery database system
i have the classes all perfect.
ahhh okay
just writing the loop now
i need a while loop a for loop and if else statements
i want to maybe nest the loop if that makes sense
whatever is easier for me bc im dying
i love gintama
I would suggest not to use any loops here, have some functions for each of your modules and just call it
class Style {
public void showOptions() {
System.out.println("Options for Style:");
// List Style-specific options here
}
}
public class Main {
public static void main(String[] args) {
Scanner scanner = new Scanner(System.in);
System.out.println("Enter a number (1 or 2): ");
int choice = scanner.nextInt();
switch (choice) {
case 1:
System.out.println("You chose to create. Pick an option:");
System.out.println("1: Style\n2: Car\n3: Umbrella");
int createChoice = scanner.nextInt();
handleCreation(createChoice);
break;
case 2:
System.out.println("You chose option 2.");
// Implement option 2 functionality here
break;
default:
System.out.println("Invalid initial choice.");
break;
}
scanner.close();
}
private static void handleCreation(int choice) {
switch (choice) {
case 1:
new Style().showOptions();
break;
default:
System.out.println("Invalid option for creation.");
break;
}
}
this is using the scanner, but you can use whatever you want