subject

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.");
}

ansver
Answers: 1

Another question on Computers and Technology

question
Computers and Technology, 22.06.2019 14:20
Consider a byte-addressable computer with 16mb of main memory, a cache capable of storing a total of 64kb of data and block size of 32 bytes. (a) how many bits in the memory address? (b) how many blocks are in the cache? (c) specify the format of the memory address, including names and sizes, when the cache is: 1. direct-mapped 2. 4-way set associative 3. fully associative
Answers: 2
question
Computers and Technology, 22.06.2019 15:30
Which of the following examples has four beats in each measure?
Answers: 2
question
Computers and Technology, 23.06.2019 20:00
What software programs are used to to create professional publication? a.) graphics programs b.) word processors c.) page layout programs d.) spreadsheet programs
Answers: 2
question
Computers and Technology, 24.06.2019 11:00
These statements describe lists in presentation programs: a. bullets can be turned off and on. b. bullets cannot be turned off. c. bullet styles, colors, and sizes can be changed. d. lists don't have to use bullets or numbers. e. numbering styles, colors, and sizes can be changed. f. numbers can be turned off and on. g. numbers cannot be turned off. select all that apply
Answers: 2
You know the right answer?
Assuming that the valid cost should be between 100 and 200, does the following code snippet test thi...
Questions
question
Mathematics, 26.08.2020 09:01
question
Mathematics, 26.08.2020 09:01
question
History, 26.08.2020 09:01
question
Geography, 26.08.2020 09:01
question
Mathematics, 26.08.2020 09:01
question
English, 26.08.2020 09:01
Questions on the website: 13722361