Question:
THIS IS NOT A BUG please check and give me advice on what I am doing wrong my output is this
sh -c javac -classpath .:target/dependency/* -d . $(find . -type f -name '*.java')
java -classpath .:target/dependency/* Main
exit status -1
import java.io.*;
import java.util.*;
public class MovieReviewProgram {
public static void main(String[] args) {
Scanner scanner = new Scanner(System.in);
try {
// Create a writer to save movie reviews to a file
BufferedWriter writer = new BufferedWriter(new FileWriter("movie_reviews.txt", true));
System.out.println("Welcome to Movie Review Program!");
System.out.print("Please enter your name: ");
String userName = scanner.nextLine();
boolean continueWriting = true;
while (continueWriting) {
// Display movie options for the user to choose from
System.out.println("Please choose a horror movie to review: ");
System.out.println("1. Insidious");
System.out.println("2. The Conjuring");
System.out.println("3. Hereditary");
System.out.println("4. Exit");
// Read the user's choice
int choice = scanner.nextInt();
scanner.nextLine(); // Consume newline character
String movieName = "";
switch (choice) {
case 1:
movieName = "Insidious";
break;
case 2:
movieName = "The Conjuring";
break;
case 3:
movieName = "Hereditary";
break;
case 4:
continueWriting = false;
break;
default:
// Invalid choice; prompt the user to choose a valid option
System.out.println("Invalid choice. Please choose a valid option.");
continue;
}
if (continueWriting) {
// Prompt the user to write a review within a specific word limit
System.out.println("Hello, " + userName + "! Please write your review for '" + movieName + "' (between 50 and 200 words): ");
String review = scanner.nextLine();
if (review.length() < 50 || review.length() > 200) {
// Review length doesn't meet the required range; ask the user to try again
System.out.println("Review length should be between 50 and 200 words. Please try again.");
} else {
// Write the user's review to the file
writer.write("User: " + userName);
writer.newLine();
writer.write("Movie: " + movieName);
writer.newLine();
writer.write("Review: " + review);
writer.newLine();
writer.newLine(); // Add an extra newline for readability
System.out.println("Review saved successfully!");
}
}
}
// Close the writer and provide a closing message
writer.close();
System.out.println("Thank you for using Movie Review Program!");
} catch (IOException e) {
// Handle any errors that occur during file writing
System.err.println("An error occurred while writing the review to the file.");
e.printStackTrace();
} finally {
// Close the scanner when done
scanner.close();
}
}
}
Question:
THIS IS NOT A BUG TO MY KNOWLEDGE; what am I doing wrong or is the code fine and the system just bugged at the moment. I keep getting a output of
sh -c javac -classpath .:target/dependency/* -d . $(find . -type f -name '*.java')
java -classpath .:target/dependency/* Main
exit status -1
Repl link/Link to where the bug appears:
MovieReviewProgram (1) - Replit
Screenshots, links, or other helpful context:
Also now it is giving me this as a output: