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

1 Expert Approved Answer
Step: 1 Unlock

Heres the corrected code with explanations for the fixes import javautilScanner Your program descrip... View full answer

blur-text-image
Question Has Been Solved by an Expert!

Get step-by-step solutions from verified subject matter experts

Step: 2 Unlock
Step: 3 Unlock

Students Have Also Explored These Related Programming Questions!