Question: I am running this code and everything is working but I keep getting the below error. Please help? import java.util.Scanner; public class Transaction { public

I am running this code and everything is working but I keep getting the below error. Please help?

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();

int totalCost = 0; if (numCookies >= 4) { totalCost = numCookies * 3; }

if (totalCost

if (numCookies > 22) { System.out.println("Restocking soon."); } else { System.out.println("Item still in stock."); }

} }

I am running this code and everything is working but I keep

First, the first if statement checks the number of cookies purchased. If at least 4 cookies are purchased, then a nested if-else statement compares the cost of the cookies to the amount of read from input. Lastly, an if-else statement outputs "Restocking soon." if more than 22 cookies are purchased, and otherwise outputs "I stock." Not all tests passed. 1: Compare output Input Your output 2: Compare output A Output differs. See highlights below. Input Your output Expected output 3: Compare output Input

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!