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
- How many 2/8 pound patties can she make from 7/8 of a pound of hamburger...
- Fictional Corp has a data center that runs multiple internal applications. However, they want to mig...
- States and explain 10 uses of computer in your field of studies...
- Should variable names have logical identifier to provide some sort of context for what they will sto...
- How does communication increase engagement
- How does a bag represent a variable?
- The system's menu screen of a television allows the user to adjust the brightness and color composit...
- Suppose that a particular algorithm has time complexity T(n) = 3 \times 2^nT(n)=3×2 n and that e...
- Write a split_check function that returns the amount that each diner must pay to cover the cost of t...
- List and describe the three types of reports.