Question: Integers numCookies and dollars are read from input. A cookie costs 3 dollars. - If numCookies is less than 4, output Please purchase at least

 Integers numCookies and dollars are read from input. A cookie costs

Integers numCookies and dollars are read from input. A cookie costs 3 dollars. - If numCookies is less than 4, output "Please purchase at least 4." - If numCookies is greater than or equal to 4, then declare and initialize int variable totalCost with the product of numcookies and 3. - If totalCost is less than or equal to dollars, output "Cookies successfully purchased." - Otherwise, output "Not enough money to buy all." - If dollars is greater than or equal to 3 , output "At least one item was purchased." - If numCookies is greater than 40 , output "Now out of stock." End with a newline. Ex: If the input is 1993 , then the output is: Cookies successfully purchased. At least one item was purchased

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!