Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

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

blur-text-image

Get Instant Access to Expert-Tailored Solutions

See step-by-step solutions with expert insights and AI powered tools for academic success

Step: 2

blur-text-image_2

Step: 3

blur-text-image_3

Ace Your Homework with AI

Get the answers you need in no time with our AI-driven, step-by-step assistance

Get Started

Recommended Textbook for

How To Build A Million Dollar Database

Authors: Michelle Bergquist

1st Edition

0615246842, 978-0615246840

More Books

Students also viewed these Databases questions

Question

Working with other project stakeholders for support.

Answered: 1 week ago

Question

Knowledge of project management (PMI) teachings

Answered: 1 week ago