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
Get step-by-step solutions from verified subject matter experts
