// variables to save fields given by the user
int years_left =0;
int amount=0;
int flag =0; // to check if both fields are valid
// while loop
while ( years_left >0 && amount >0){
// taking years left as input
cout<<" Enter the years left for your retirement: ";
cin>>years_left;
// if valid add in flag variable
if(years_left>0){
flag +=1;
}
// input amount saved annually
cout<<" Enter the amount of money saved annually : ";
cin>> amount;
// if valid flag ++
if(amount>0)
flag+=1;
// if both fields are vaild, out put them
if(flag==2)
{
cout<<" Years left are : " << years_left<< endl;
cout<<" Amount saved annually : " << amount <<endl;
}
flag = 0;
}