you have twice case'I'
the compiler doesn't like that at all
on top of that
1 2
case'I': // <-- colon not semicolon
case'O': // <-- same here
aaand don't forget "break" at the end:
1 2 3
case'I': { //some code
break; //without this your programm will execute whatever code comes after "case 'O':" as well (doesn't matter if the character was 'I')
}
switch (selection)
{
// case 'I'; // remove this
case'I': { //added here ":" and "{"
cout<< "How many days did you spend in the hospital?"<< endl;
cin >> days;
cout << "what is the daily rate?"<< endl;
cin >> rate;
cout<< "hospital charges"<< endl;
cin>>charges;
cout<< "please enter medicine charges"<< endl;
cin >> medicine;
cout << calctotal(days, rate, medcine, charges)<< endl;
break; //added here break;
} //added here "}" between {} was now your code block when your character is 'I'
case'O': { // changed ; to : and added "{"
cout<< "charges by the hospital"<< endl;
cin>> charges;
cout<<"medicine charges"<< endl;
cin>>medicine;
cout<< calctotal(charges, medicine);
break; // added break; (wasn't necessary because there isn't anything following that blockcode inside the switch statement anyway)
} // added "}" => betwee these {} is your codeblock for "case 'O'"
}
//switch (selection) //remove this
well you seem to be calling a function called "calctotal" that doesn't exist (if the code you posted is everything you have then it really doesn't exist)
=> you have to declare the function and program whatever it is supposed to do.
double calctotal(int, double, double, double);{(int days* double rate)+ double charges+ double medicine
}
double calctotal(double, double); {double charges+ double medicine} am i supposed to do it like this? its still giving me problems.