Question: Totally lost on how to start this code. Integers numCookies and numDollars are read from input. A cookie costs 3 dollars. If numCookies is greater

Totally lost on how to start this code.

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

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 numDollars, output "Successful purchase!"

Otherwise, output "Need more money to purchase all."

If numCookies is greater than 22, output "Restocking soon." Otherwise, output "Item still in stock."

End with a newline.

Ex: If the input is 11 54, then the output is:

Successful purchase! Item still in stock.

import java.util.Scanner;

public class Transaction { public static void main (String[] args) { Scanner scnr = new Scanner(System.in); int numCookies; int numDollars; numCookies = scnr.nextInt(); numDollars = scnr.nextInt();

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!