Hey
I am creating a basic currency converter. I have a simple menu but the problem is there is no error control. Here is the code...
Basically, I was the menu to show the first time the App is executed. Then if the user enters a selection higher than 5, they get an error. The menu is shown again ready for them try again.Code:void menu(void) { int menu; int valid = 0; printf(" *****Menu*****\n\n1. Pounds to Euro\n2. Pounds to USD\n3. Pounds to Chinese Yen\n4. Pounds to Australian dollar\n5. Pounds to Canadian dollar\n\n"); cin >> menu; //this won't work with scanf for some reason switch(menu) { case 1: rate = 1.48018; strcpy(convertto, "euros"); valid = 1; break; case 2: rate = 1.94849; strcpy(convertto, "USD"); valid = 1; break; case 3: rate = 15.288; strcpy(convertto, "chinese yen"); valid = 1; break; case 4: rate = 2.4932; strcpy(convertto, "australian dollars"); valid = 1; break; case 5: rate = 2.2014; strcpy(convertto, "canadian dollars"); valid = 1; break; } }
Any help would be appreciated.