Solved

Assuming That a Valid Price Should Be Between 30 and 50

Question 65

Multiple Choice

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.

Correct Answer:

verifed

Verified

Unlock this answer now
Get Access to more Verified Answers free of charge

Related Questions

Unlock this Answer For Free Now!

View this answer and more for free by performing one of the following actions

qr-code

Scan the QR code to install the App and get 2 free unlocks

upload documents

Unlock quizzes for free by uploading documents