1answer.
Ask question
Login Signup
Ask question
All categories
  • English
  • Mathematics
  • Social Studies
  • Business
  • History
  • Health
  • Geography
  • Biology
  • Physics
  • Chemistry
  • Computers and Technology
  • Arts
  • World Languages
  • Spanish
  • French
  • German
  • Advanced Placement (AP)
  • SAT
  • Medicine
  • Law
  • Engineering
Pie
3 years ago
6

Assuming that a valid price should be between 30 and 50, does the following code snippet test this condition correctly?final int

MIN_PRICE = 30; final int MAX_PRICE = 50; int price = 0; Scanner in = new Scanner(System.in);System.out.print("Please enter the price: ");price = in.nextInt();if (price < MIN_PRICE){ System.out.println("Error: The price is too low.");} else if (price > MAX_PRICE) { System.out.println("Error: The price is too high.");} else{ System.out.println("The price entered is in the valid price range.");}a) This code snippet ensures that the price value is between 30 and 50.b) This code snippet only ensures that the price value is greater than 30.c) This code snippet only ensures that the price value is less than 50.d) This code snippet ensures that the price value is either less than 30 or greater than 50
Computers and Technology
1 answer:
san4es73 [151]3 years ago
3 0

Answer

A) This code snippet ensures that the price value is between 30 and 50

Explanation:

The code snippet given ensures that the acceptable price values lies in the range of 30 and 50 inclusive of the lower and upper bound values. This condition is enforced with the the if...else if... else statements.

The first if statement;

if (price < MIN_PRICE){

           System.out.println("Error: The price is too low.");

}  checks if user inputted price is less that the MIN_PRICE which is 30 and displays the error message.

The second, an else if statement;

else if (price > MAX_PRICE) {

           System.out.println("Error: The price is too high.");

       } This checks if the user inputted price is above the MAX_PRICE which is 50 and displays the error message.

finally the else statement; else{ System.out.println("The price entered is in the valid price range.");

       } Prints the message confirming a valid price.

You might be interested in
write an algorithm that gets the price for item A plus the quantity purchased. The algorithm prints the total cost, including a
I am Lyosha [343]

Answer:

<u>Algorithm() </u>

1. p = Enter the price of item A.

2. c = Enter the number of A’s purchased.

3. Now the price per item with tax is:

              t= p+(p*6/100)

4. The total cost of c items:  

             ct= t * c.

5. Print ct.

In this algorithm, we are taking the price per item and counting it’s cost including tax. Then we are multiplying the price per item with tax with the number of items we purchase, to find the overall cost with tax.

You may calculate the overall cost without tax as (p*c). Then you can find the overall cost with tax as ((p*c)+(p*c*6/100)), as in both way, we will get the same result.

4 0
3 years ago
Class 10 computer unit 1 all excersise​
kenny6666 [7]
Y’all just asking for people do your work, literally not even a question
5 0
3 years ago
I need urgent help...my laptop has been like this... can anyone help me plzzz​
lukranit [14]

Answer:

I think you have to restart your device.

6 0
3 years ago
A common attack in which a client's cookies, security tokens, or other personal information is obtained and used to impersonate
o-na [289]

Answer:

Identity Theft. i hope this helps :D

5 0
3 years ago
Write an if/else statement that compares the value of the variables soldYesterday and soldToday, and based upon that comparison
jenyasd209 [6]

Answer:

if(soldYesterday > soldToday){

salesTrend = -1;

} else if(soldToday > soldYesterday){

salesTrend = 1;

}

Explanation:

The if/else statement is more explicit. The first if condition check if soldYesterday is greater than soldToday, if true, then -1 is assigned to salesTrend.

Else if soldToday is greater than soldYesterday, if true, then 1 is assigned to salesTrend.

7 0
3 years ago
Other questions:
  • The arrow next to All Programs indicates _____. that this item cannot be selected that this was the most recently used item the
    7·2 answers
  • 110101111.11011 to decimal (base 10)
    6·1 answer
  • Edhesive coding practice 3.4​
    12·1 answer
  • What is an instruction set architecture​
    7·2 answers
  • You are creating a presentation and you have come to the last slide. You still have more information to add. What should you do?
    7·1 answer
  • What happens if the addressed device does not respond due to a malfunction during a read operation?
    11·1 answer
  • When an external device becomes ready to be serviced by the processor the device sends a(n)_________ signal to the processor.
    8·1 answer
  • Which element is represented by the electron configuration in example B? Example B: 1s22s22p63s23p64s1 Aluminum Cesium Potassium
    12·2 answers
  • Why is my speedtest is very good but chrome is slow
    11·1 answer
  • How do you get lugia in pokemon alpha saphire
    6·1 answer
Add answer
Login
Not registered? Fast signup
Signup
Login Signup
Ask question!