We were given a problem like this:
Compute for the total tuition fee of a student based on the course given.
Year Level Description Course Rate
1 Freshman BSIT 225.40
2 Sophomore BS-CS 423.42
3 Junior Mgt 234
4 Senior Finance 425.31
Input no. of units, downpayment, and year level. Ouput total tuition fee, balance, and description of year level.
If you really want to make one for each combination, you can do this:
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15
struct Two
{
int A, B;
Two(constint& a, constint& b)
{
A = a;
B = b;
}
}
const Two PossibilityA (0,0);
const Two PossibilityB (1,0);
const Two PossibilityC (0,1);
//etc
1 2 3 4 5 6 7 8 9 10 11 12 13
Two Input;
cin >> Input.A;
cin >> Input.B;
switch(Input)
{
case PossibilityA:
//do stuff
case PossibilityB:
//do more stuff
case PossibilityC:
//do even more stuff, etc etc
int main ()
{
char Color;
int Fruit;
printf("Chose what fruit you want:\n");
printf("1-Apple\n");
printf("2-Orange\n");
scanf("%d",&Fruit);
switch(Fruit){
case 1: printf("Ok..so we have 2 types of apples:\n");
printf("R-Red apples\n");
printf("G-Green apples\n");
Color=getche(); //the bug is somewhere here(i think :))
switch(Color){
case'r':
case'R' : printf("Ty for buying red apples.10 $ please %c\n",1);
break;
case'v' :
case'V' : printf("Ty for buying green apples.12$ please %c\n",1);
break;
default : printf("Wrong option..u blind or what?\n");
}
break;
case 2: printf("Damn..where out of oranges\n");
printf("1-Report the problem\n");
printf("2-Then get out of my shop\n");
//and maybe another switch/case
break;
default : printf("Wrong option..u blind or what?\n");
}
printf("\nPress Enter to continue");
getchar();
return 0;
}
sry for the bad formatting,just pasted it from vs and it is a bit displaced..don't now why.
So my problem is not the menu itself,y got the idea and it works fine but,the problem is when i thy to read the options from the keyboard.if y had int values,there would be no problem,but y need some char to..and my getchar() skips the second switch..i tried to use getche(),witch does not wait for you to press enter(no ecko )..and y am starting to thing that the enter thing may be the problem..tried printf("%c"&Color); but skips also..so how can y read the char options so that is going trough all switches.TY