switch(choice)
{
case'A':
case'a':
cout<<"Enter value in KM: ";
cin>>km;
m=km*1000;
cout<<km<<" KM is equal to "<<m<<" M\n";
break;
case'B':
case'b':
cout<<"Enter value in M: ";
cin>>m;
cm=m*100;
cout<<m<<" M is equal to "<<cm<<" CM\n";
break;
case'C':
case'c':
cout<<"Enter value in CM: ";
cin>>cm;
mm=cm*10;
cout<<cm<<" CM is equal to "<<mm<<" MM\n";
break;
case'D':
case'd':
return 0;
break;
default:
cout<<"Invalid Input\nEnter Choice again: ";
cin>>choice;
}
}while (choice=='A'||choice=='a'||choice=='B'||choice=='b'||choice=='C'||choice=='c'||choice=='D'||choice=='d');
Im trying to make the user input again until the value becames valid
the problem is when i try it, it only ask 2 times then exits...
this is the last problem thats being a burden to my sleep Y_Y
Perhaps you need to look at your logic again. I have to say I'm not 100% sure what you're trying to do, but I'll take a stab...
1. DO: Get a character from input, assign that value to 'choice'
- Keep repeating WHILE (tolower(choice) != 'a') || (tolower(choice) != 'b' etc...
2. Process the valid character like you're doing in your case statements
If you want to repeat the entire process, you need to put a loop around the entire thing.
Hope that helps. Feel free to post your next attempt if you're still stuck...