Hey guys I have a question about some inputs and when to stop.
So I am suppose to have the user input day, the high temperature for the day, the record high temp, the year it was recorded and the humidity percentage. I am suppose to have these sent into an array, and when the user decided to stop entering the data they have to enter 0 into all the fields and quit. I am having trouble doing this and just wanted some advice.
this is currently what my code looks like for that area.
ix = 0;
do
{
cout << endl << "Enter the five data fields. ""When you are done enter 0 for all fields." << endl;
cout << endl << "Enter the day " << endl;
cout << "(Counting from beginning of year for example: ""February 2 is 33): ";
cin >> day[ix];
cout << endl << "Enter the high temperature (degrees Fahrenheit): ";
cin >> highTemp[ix];
cout << endl << "Enter the record high temperature ""(degrees Fahrenheit): ";
cin >> recordHigh[ix];
cout << endl << "Enter the year the record high temperature"" was recorded: ";
cin >> yearRecord[ix];
cout << endl << "Enter the relative humidity (in percent): ";
cin >> humidityPercent[ix];
++ix;
}
while (day[ix] != 0);
#include <iostream>
usingnamespace std ;
int main()
{
constexprint MAX = 10 ; // ****
int day[MAX] ;
double highTemp[MAX], recordHigh[MAX], yearRecord[MAX], humidityPercent[MAX] ;
int ix = 0;
do
{
cout << endl << "Enter the five data fields. ""When you are done enter 0 for the day." << endl; // ***
cout << endl << "Enter the day " << endl;
cout << "(Counting from beginning of year for example: ""February 2 is 33): ";
cin >> day[ix];
if ( day[ix] == 0 ) break ; // ****
cout << endl << "Enter the high temperature (degrees Fahrenheit): ";
cin >> highTemp[ix];
cout << endl << "Enter the record high temperature ""(degrees Fahrenheit): ";
cin >> recordHigh[ix];
cout << endl << "Enter the year the record high temperature"" was recorded: ";
cin >> yearRecord[ix];
cout << endl << "Enter the relative humidity (in percent): ";
cin >> humidityPercent[ix];
++ix;
}
while( ix < MAX ) ; // ****
}