Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

In Java PLEASE! Integers numPears and numDollars are read from input. A pear costs 2 dollars. If numPears is less than 4 , output Not

In Java PLEASE!
Integers numPears and numDollars are read from input. A pear costs 2 dollars.
If numPears is less than 4, output "Not enough pears."
If numPears is greater than or equal to 4, then declare and initialize int variable totalCost with the product of numPears and
If totalCost is less than or equal to numDollars, output "Approved transaction."
Otherwise, output "Not enough money to buy all."
If numDollars is greater than or equal to 2, output "At least one item was purchased."
If numPears is greater than 25, output "Now out of stock." Otherwise, output "Item still in stock."
End with a newline.
Ex: If the input is 1044, then the output is:
Approved transaction.
At least one item was purchased.
Item still in stock.
import java.util.Scanner;
public class PearPurchases {
public static void main (String[] args){
Scanner scnr = new Scanner(
System.in);
int numPears;
int numDollars;
numPears = scnr. nextInt ();
numDollars = scnr. nextInt ();
Y** Your code goes here */
}
}
image text in transcribed

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

Advances In Spatial And Temporal Databases 10th International Symposium Sstd 2007 Boston Ma Usa July 2007 Proceedings Lncs 4605

Authors: Dimitris Papadias ,Donghui Zhang ,George Kollios

2007th Edition

3540735399, 978-3540735397

More Books

Students also viewed these Databases questions

Question

Spell out the IUPAC name of the compound

Answered: 1 week ago

Question

How to find if any no. is divisble by 4 or not ?

Answered: 1 week ago

Question

Explain the Pascals Law ?

Answered: 1 week ago

Question

What are the objectives of performance appraisal ?

Answered: 1 week ago