Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

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."); }

} }

image text in transcribed

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

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

Concepts Of Database Management

Authors: Joy L. Starks, Philip J. Pratt, Mary Z. Last

9th Edition

1337093424, 978-1337093422

More Books

Students also viewed these Databases questions

Question

What kinds of communication help sustain long-distance romances?

Answered: 1 week ago