Question
Here's a Java code below that I need to get working correctly when compiling and running: import java.util.Scanner; /** * Interactive Java program to share
Here's a Java code below that I need to get working correctly when compiling and running:
import java.util.Scanner;
/**
* Interactive Java program to share information about favorite things. [Expand more with information of what this program is and what it does]
*
* @author Williams, Stanley
* @assignment ICS 111 Assignment 04
* @date February 4, 2024
* @bugs None
*/
public class WilliamsStanley04 {
public static void main(String[] args) {
Scanner input = new Scanner(System.in);
System.out.println("Hi there, what's your name?");
String name = input.nextLine();
System.out.println("Hey, " + name + "! Do you want to hear about some of my favorite video games at the moment? Enter yes to continue: ");
String response = input.nextLine();
if (response.equalsIgnoreCase("yes")) {
System.out.println("Okay! Which game would you like to hear about?");
System.out.println("Press 1 to hear about Call of Duty");
System.out.println("Press 2 to hear about Final Fantasy XIV");
System.out.println("Press 3 to hear about Animal Crossing: New Horizons");
int choice = input.nextInt();
switch (choice) {
case 1:
System.out.println("Call of Duty");
//... Add description of the game
break;
case 2:
System.out.println("Final Fantasy XIV");
//... Add description of the game
break;
case 3:
System.out.println("Animal Crossing: New Horizons");
//... Add description of the game
break;
default:
System.out.println("Invalid choice!");
System.out.println("So, what do you think? Would you be interested in checking out this game? ");
String feedback = input.nextLine();
if (feedback.equalsIgnoreCase("yup, sounds great!")) {
System.out.println("Really?! Awesome! Here, you can borrow my Switch and try it out! :)");
else {
System.out.println("Okay, maybe next time! Have a great day! :)");
else {
System.out.println("Alright, see you next time!");
}
}
------------------
Here's the 3 errors that I keep getting in jGRASP when compiling:
----jGRASP exec: javac -g WilliamsStanley04.java
WilliamsStanley04.java:50: error: 'else' without 'if'
else {
^
WilliamsStanley04.java:47: error: reached end of file while parsing
else {
^
WilliamsStanley04.java:53: error: reached end of file while parsing
}
^
3 errors
----jGRASP wedge2: exit code for process is 1.
----jGRASP: operation complete.
Step by Step Solution
3.36 Rating (146 Votes )
There are 3 Steps involved in it
Step: 1
Heres the corrected code with explanations for the fixes import javautilScanner Your program descrip...Get Instant Access to Expert-Tailored Solutions
See step-by-step solutions with expert insights and AI powered tools for academic success
Step: 2
Step: 3
Ace Your Homework with AI
Get the answers you need in no time with our AI-driven, step-by-step assistance
Get Started