After spending some more time with this, the code now works. I would like some help in coding the error statement.
1) If the user enters an age, say below 1 or exceeding 120, the user shd get an error message "Warning, age must be between 1 and 120" hence(!(1<=ageValue&&ageValue<=120)), and then the user must be prompted again to enter a valid age.
2) If the user enters a non-int value, the message is "Error: invalid entry" and prgm exits the loop. Where would be best to input these two messages? THANKS!
/ reading values printing out input in reverse
//**********************************************************************
#include
using namespace std;
const int MAX=1000;
int main()
{
int ageValue[MAX];
int count=0;
char choice;
cout<<"Enter the age of the youngest family member:"<
cin>>ageValue[count];
cout<<"Are there any more family members?(Y for yes and N for no)"<
cin>>choice;
for(count=1; choice=='Y'||choice==
2006-07-23
14:49:17
·
3 answers
·
asked by
jdegbor
1
in
Computers & Internet
➔ Programming & Design
for(count=1; choice=='Y'||choice=='y'; count++)
{
cout<<"Enter the age of the next youngest person"<
cin>>ageValue[count];
cout<<"Are there any more family members?(Y for yes and N for no)";
cin>>choice;
}
cout<<"Thank you. The ages of your family in reverse order are:"<
while(count>0)
{
count--;
cout<<" "<
}
return 0;
}
2006-07-23
14:50:29 ·
update #1