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

1 Expert Approved Answer
Step: 1 Unlock 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 Databases Questions!