Assuming that the valid cost should be between 100 and 200, does the following code snippet test this condition correctly?
final int MIN_COST = 100;
final int MAX_COST = 200;
int cost = 0;
Scanner in = new Scanner(System.in);
System.out.print("Please enter the cost: ");
cost = in.nextInt();
if (cost < MIN_COST)
{
System.out.println("Error: The cost is too low.");
}
else if (cost > MAX_COST)
{
System.out.println("Error: The cost is too high.");
}
else
{
System.out.println("The cost entered is in the valid cost range.");
}
Computers and Technology
Views: 0 Asked: 01-03 01:11:25
On this page you can find the answer to the question of the computers and technology category, and also ask your own question
Other questions in category
- What is a man-in-the-middle attack
- If you are inviting more than one person to a meeting, you can use a(n) _____ to separate the email ...
- Write a split_check function that returns the amount that each diner must pay to cover the cost of t...
- Which prosscess is a form of mechanicel weathering
- 50+ Points Brainlist the best answer
- Choose all items that represent characteristics of a work samples....
- Biometric authentication can’t be reset. TRUE or FALSE
- What are the unique ICT needs for casinos?
- How does a bag represent a variable?
- Why is this app here to help but wont let me see answers to my questions?...