Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

CS 1301- Intro to CS Week 4 Exercise public static void nain(Stringt) args) System.out.print In(Happy Valentine's day!) Scanner scanner new Scanner (Systen.); int nunkisses 3;

image text in transcribed
CS 1301- Intro to CS Week 4 Exercise public static void nain(Stringt) args) System.out.print In("Happy Valentine's day!) Scanner scanner new Scanner (Systen."); int nunkisses 3; int nunebsnacit askango 3 boolean keepGoing true: while (keepGoing) System.out.printin"numkisses nunkisses): System.out.print In("numReesesnunReeses); System.out.print In ("numRebanaditasMango"numRebanaditasMango): System.out.println("Enter if you want a kiss (Hershey's)"); System . out.println("Enter 1 if you want a reese's chocolate heart" System.out.print ln("Enter 2 if you want a rebanadita de mango"): System.out.printn"Enter 3 if you want to exit") int choice scanner.nextIntO: if (choice 0) nunkisses-1: else if (choice1) numReeses1: else if (choice2) numRebanaditasMango -1 else keepGo ingfalse A. B. Replace all the if statements with a switch statement Modify the code, so the none of the integer values becomes negative. When the user selects something you don't have, print a message letting the user know you ran out Modily the Boolean expression/ condition of the while loop, so the program terminates when you run out of candy. C

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

Step: 3

blur-text-image

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

Time Series Databases New Ways To Store And Access Data

Authors: Ted Dunning, Ellen Friedman

1st Edition

1491914726, 978-1491914724

More Books

Students also viewed these Databases questions