I am trying to make a code that will identify what color the wavelength is associated with.
I only have to provide for the error that the individual inputs a number outside of the range .400-.700
I have created a code that when a number is entered it looks similar to the matrix screen. Any suggestions? ANYTHING will help. I want to think my loop is off, but I don't know how to fix it. PLEASE and THANK YOU for any help.
//setup standard environment
#include <iostream>
using namespace std;
int main()
{
// variable declarations
int wave_length;
int i; //loop counter
int counter=0; //initialize counter
const int max_iterations =3; //maximum number of times for error loop
const int max_char = 30; //maximum numbers of characters
// Output program name
cout << endl; // Setups two blank lines before program name
cout << endl;
do
{
//output data to display
cout<< "Please enter the wavelength in microns to the thousandth decimal place (Valid entries 0.400-0.700): ";
cin>> wave_length;
if (wave_length >= .400 && wave_length <=.700)
{
if (wave_length <= 0.424)
cout<< "The associated color is Violet." <<endl;
else if (wave_length > 0.424 && wave_length <= 0.491)
cout<< "The associated color is Blue." <<endl;
else if (wave_length >0.491 && wave_length <=0.575)
cout<< "The associated color is Green." <<endl;
else if (wave_length >0.575 && wave_length <=0.585)
cout<< "The associated color is Yellow." <<endl;
else if (wave_length >0.585 && wave_length <=0.647)
cout<< "The associated color is Orange." <<endl;
else if (wave_length>0.585 && wave_length <=0.700)
cout <<"The associated color is Red." <<endl;
}
else
cout << "Wavelength outside visual range." <<endl;
Oh wow, thank you so much. You made my day. I got double in there, and it seemed to be working correctly. However, it isn't stopping the loop after 3 times. or the max_iterations.
Any suggestions?
once again, thank you. You have no idea how much I appreciate this.