Here's the error codes that I'm still getting below for one of the java programs in jGrasp:
Question:
Here's the error codes that I'm still getting below for one of the java programs in jGrasp:
----jGRASP exec: javac -g WilliamsStanley04.java
WilliamsStanley04.java:75: error: reached end of file while parsing
scanner.close();
^
WilliamsStanley04.java:69: error: reached end of file while parsing
else {
^
WilliamsStanley04.java:65: error: reached end of file while parsing
else {
^
WilliamsStanley04.java:63: error: reached end of file while parsing
else if (feedback.equals("bad")) {
^
WilliamsStanley04.java:61: error: reached end of file while parsing
else if (feedback.equals("okay")) {
^
5 errors
----jGRASP wedge2: exit code for process is 1.
----jGRASP: operation complete.
---------------------------------------------------------------------------------------------------------
Here's the code that was supposed to have been corrected but this code is still giving me 5 errors:
import java.util.Scanner;
/
* Interactive Java program to share information about favorite things.
*
* @author Williams, Stanley
* @assignment ICS 111 Assignment 04
* @date February 4, 2024
* @bugs None
*/
public class WilliamsStanley04 {
public static void main(String[] args) {
// Create a Scanner object to read user input
Scanner scanner = new Scanner(System.in);
// Ask the user if they'd like to hear about a favorite thing
System.out.println("Would you like to hear about one of my favorite things? (yes/no)");
String userResponse = scanner.nextLine().toLowerCase();
// Check user's response
if (userResponse.equals("yes")) {
// Present a list of choices
System.out.println("Great! Choose one of the following:" +
"1. Favorite Book" +
"2. Favorite Movie" +
"3. Favorite Restaurant");
// Get user's choice
int userChoice = scanner.nextInt();
// Use switch statement to handle different choices
switch (userChoice) {
case 1:
// User choose Favorite Book
System.out.println("One of my favorite books is 'The Master Key System.' It's a classic novel with a powerful message.");
break;
case 2:
// User choose Favorite Movie
System.out.println("One of my favorite movies is 'Fist of Fury.' It's a compelling story about hope and redemption.");
break;
case 3:
// User choose Favorite Restaurant
System.out.println("One of my favorite restaurants is 'Cheesecake Factory.' They serve delicious Italian cuisine.");
break;
default:
// User entered an invalid choice
System.out.println("Invalid choice. Program exiting.");
return; // Exit the program
// Ask for feedback on the chosen item
scanner.nextLine(); // Consume the newline character
System.out.println("What do you think about the chosen item? (good/okay/bad)");
String feedback = scanner.nextLine().toLowerCase();
// Provide different responses based on user feedback
if (feedback.equals("good")) {
System.out.println("I'm glad you liked it!");
else if (feedback.equals("okay")) {
System.out.println("Well, everyone has their own taste!");
else if (feedback.equals("bad")) {
System.out.println("Sorry to hear that. I appreciate your honesty.");
else {
System.out.println("Invalid feedback. Program exiting.");
return; // Exit the program
else {
// User doesn't want to hear about favorite things
System.out.println("Okay, maybe next time. Program exiting.");
// Close the scanner
scanner.close();
Income Tax Fundamentals 2013
ISBN: 9781285586618
31st Edition
Authors: Gerald E. Whittenburg, Martha Altus Buller, Steven L Gill