0
The user types the year, month, day and temperature, but I need to limit the answers.
ano
may not be less than1850
and greater than2021
mes
may not be less than1
and greater than12
,dia
may not be less than1
and cannot be greater than31
temperatura
may not be less than-50
and greater than65
.
I tried that check but it won’t ...
cout<<"\nPor favor digite o dia: ";
cin>>dia[i];
cout<<"\nPor favor digite o mês: ";
cin>>mes[i];
cout<<"\nPor favor digite o ano: ";
cin>>ano[i];
cout<<"\nPor favor digite a temperatura: ";
cin>>temperatura[i];
cout<<"\n++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++\n";
if ((dia[i] > 30) || (mes[i] > 12) || (ano[i] < 1850 > 2021)) {
cout<<"\nAlgo esta inválido";
}
The program prints a message saying something is invalid.
You could put in the rest of the code so we can get an overview of the problem?
– Gabriel Gomes Nicolim
Apart from you not being validating some things, this is invalid:
ano[i] < 1850 > 2021
. You need to check one part at a time:ano[i] < 1850 || ano[i] > 2021
.– Rafael Tavares
good afternoon, so I did not put whole because it is a switch and this incomplete, I ask this information to the user and thereafter he chooses an option that will use this information for example average temperatures...
– Eloisa Anibaletto
cool maybe that I did wrong even not to check one thing at a time... thank you
– Eloisa Anibaletto