Question: #include using namespace std; int main() { double wavelength; cout < < Please input a wavelength between 400.0 and 700.0: ; cin >> wavelength; if

#include using namespace std;

int main() {

double wavelength;

cout << "Please input a wavelength between 400.0 and 700.0: ";

cin >> wavelength;

if (wavelength < 400.0 || wavelength > 700.0) {

cout << "Invalid input. Please enter a wavelength between 400.0 and 700.0." << endl; return 1;

}

if (wavelength >= 400.0 && wavelength < 445.0) {

cout << "Your wavelength corresponds to the color Violet." ;

} else if (wavelength >= 445.0 && wavelength < 475.0) {

cout << "Your wavelength corresponds to the color Indigo." ;

} else if (wavelength >= 475.0 && wavelength < 510.0) {

cout << "Your wavelength corresponds to the color Blue.";

} else if (wavelength >= 510.0 && wavelength < 570.0) {

cout << "Your wavelength corresponds to the color Green." ;

} else if (wavelength >= 570.0 && wavelength < 590.0) {

cout << "Your wavelength corresponds to the color Yellow." ;

} else if (wavelength >= 590.0 && wavelength < 650.0) {

cout << "Your wavelength corresponds to the color Orange." ;

} else if (wavelength >= 650.0 && wavelength < 700.0) { cout << "Your wavelength corresponds to the color Red." ; }

cout << "Thank-you for using our program!" << endl;

return 0;

1.Re write the program to Deal with all possible inputs. If the wavelength is lesser than 400.0, the program will print the message wavelength too small.If the wavelength is greater than 700.0, the program will print the message wavelength too large. 2. Report the number of comparisons that were performed. In order to do that, define a global counter variable at the beginning of the program. Increment this variable immediately before each condition that is checked.

Step by Step Solution

There are 3 Steps involved in it

1 Expert Approved Answer
Step: 1 Unlock blur-text-image
Question Has Been Solved by an Expert!

Get step-by-step solutions from verified subject matter experts

Step: 2 Unlock
Step: 3 Unlock

Students Have Also Explored These Related Databases Questions!