Question
Fix the code so it runs. Take note of what errors are generated by the compiler. What do these errors mean? How do they help
Fix the code so it runs.
Take note of what errors are generated by the compiler. What do these errors mean? How do they help you find and fix the errors?
import java.util.Scanner;
public class Main { public static void main(String[] args) { int numOfBooks = 130; char bookStoreAns;
do { System.out.println("Are you at the book store? (y/n)"); bookStoreAns = scnr.next().charAt(0); boolean atBookStore;
if (bookStoreAns == 'y') { atBookStore = true; } else if (bookStoreAns == 'n') { atBookStore = false; } } while (bookStoreAns != 'y' && bookStoreAns != 'n');
if (atBookStore) { numOfBooks += 4; }
System.out.println("I have " + numOfBooks + " books.");
} }
Can anyone fix this code in Java?
Step by Step Solution
There are 3 Steps involved in it
Step: 1
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