Get the answers you need at Westonci.ca, where our expert community is always ready to help with accurate information. Join our Q&A platform to connect with experts dedicated to providing accurate answers to your questions in various fields. Discover detailed answers to your questions from a wide network of experts on our comprehensive Q&A platform.
Sagot :
Explanation:
Your problem arises in the user input. When taking a user input, and using the input() function, you need to ask the user something:
Instead of:
miles_per_gallon = float(input())
You need to enter text in the form:
miles_per_gallon = float(input("Enter a value: "))
This may be the format in which you included your code but remember, indentation is important so lines 3, 9, and 12 need to be indented.
Hope this helps!

Answer:Change your logic to:
for (int i = 0; i < 4; i++) {
System.out.println("Please input a number between zero to 3");
// use input and don't advance the scanner every time
int input = sc.nextInt();
if (input == 0) {
System.out.println("You have selected " + right);
}
if (input == 1) {
System.out.println("You have selected " + left);
}
// so on and so forth
}
By using sc.nextInt() four times, you are looking for the next token of the input which isn't there. So fetch the input for each run of the for-loop and it will work as expected.
Explanation:
Thank you for choosing our service. We're dedicated to providing the best answers for all your questions. Visit us again. We hope our answers were useful. Return anytime for more information and answers to any other questions you have. Keep exploring Westonci.ca for more insightful answers to your questions. We're here to help.