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 08:10
Ihave a music player on my phone. i can buy songs, add them to playlists and play them. obviously it would be redundant to store each song in each playlist; each playlist is just a list of pointers to the songs. for this lab you will simulate this behavior. your program will need to have options to: add songs to the system library (you will store the text of the first line of the song, rather than the audio) add playlists add songs to a playlist list playlists play a playlist list all of the songs in the library with a count of how many times each song has been played remove a song from a playlist remove a playlist remove a song from the library (and thus from all playlists that contain it) note that we will not be checking many error cases. in real programming this would be bad, you should usually try to recognize and respond to as many types of errors as you can. in the context of class we are trying to acquaint you with as many concepts as possible, so for the sake of educational efficiency we will not be checking most errors in this lab, you may assume that your user provides correct input. you may add all appropriate error testing if you wish, but we will not be testing for it.
Answers: 2
question
Computers and Technology, 23.06.2019 15:30
Brian wants to conduct an online search with a certain phrase. he intends to use the words books that belong to the 1800s in his search. how should he use the word that in his search?
Answers: 1
question
Computers and Technology, 23.06.2019 21:30
Which of the following includes the three primary network access technologies? dsl, cable modem, broadband lan, wan, man voip, uc, iptv tcp/ip, ftp, dhcp
Answers: 2
question
Computers and Technology, 24.06.2019 00:00
Visualizing a game of β€œtag” to remember the meaning of contagious
Answers: 3
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
Chemistry, 28.07.2019 22:00
Questions on the website: 13722367