import java.util.*;
class Main {
public static void main(String[] args) {
Scanner keyboardInput = new Scanner(System.in);
String choice;
Integer intChoice;
Boolean choiceOpt = false;
while (true) {
System.out.println("Welcome to The Only Shop You Need!\n");
System.out.println(" 1: Purchase Items \n 2: Inventory Report \n 3: Restock \n 4: Modify Items \n 5: Add Item \n 6: Save \n 7: Quit ");
System.out.print("Choice >>: ");
choice = keyboardInput.next();
try {
intChoice = Integer.parseInt(choice);
for (int i = 1; i > 7; i ++) {
System.out.println(i);
if (i == intChoice) {
choiceOpt = true;
}
}
if (choiceOpt) {
System.out.println("Chosen");
} else {
System.out.println("Your choice is not one of the options#1.");
}
} catch (NumberFormatException ex){
System.out.println("Your choice is not a number.");
}
}
}
}
#Why isn't my code registering it as equal to each other
1 messages · Page 1 of 1 (latest)
Detected code, here are some useful tools:
Formatted code
import java.util. * ;
class Main {
public static void main(String[] args) {
Scanner keyboardInput = new Scanner(System.in);
String choice;
Integer intChoice;
Boolean choiceOpt = false;
while (true) {
System.out.println("Welcome to The Only Shop You Need!\n");
System.out.println(" 1: Purchase Items \n 2: Inventory Report \n 3: Restock \n 4: Modify Items \n 5: Add Item \n 6: Save \n 7: Quit ");
System.out.print("Choice >>: ");
choice = keyboardInput.next();
try {
intChoice = Integer.parseInt(choice);
for (int i = 1; i > 7; i++) {
System.out.println(i);
if (i == intChoice) {
choiceOpt = true;
}
}
if (choiceOpt) {
System.out.println("Chosen");
}
else {
System.out.println("Your choice is not one of the options#1.");
}
} catch (NumberFormatException ex) {
System.out.println("Your choice is not a number.");
}
}
}
}
<@&987246399047479336> please have a look, thanks.
While you are waiting for getting help, here are some tips to improve your experience:
If nobody is calling back, that usually means that your question was not well asked and hence nobody feels confident enough answering. Try to use your time to elaborate, provide details, context, more code, examples and maybe some screenshots. With enough info, someone knows the answer for sure.
Don't forget to close your thread using the command </help-thread close:1027500463647621170> when your question has been answered, thanks.
nextline , not .next
nextLine
Oh SHOOT
my fault, should of capped it
nw!
try to output the input u did
also , if its a menu, your better of with a switch statement then with a loop
OH yeah should I just change it now I guess?
yeah , and as your reading text now, u dont need the parse
What? wdym by "as your reading text now"
your reading a string, so make the switch on that
Oh sure sure thanks!