Quote
int main()
{
char dayF, dayS;
double timeofcall;
int lengthofcall;
while(true){
cout << " Enter the first two initials of the day the call was made \n ";
cin >> dayF >> dayS;
if(dayF == 'm' && dayS == 'o' || dayF == 't' && dayS == 'u' || dayF == 'w' && dayS == 'e' || dayF == 't' && dayS == 'r' || dayF == 'f' && dayS == 'r' || dayF == 's' && dayS == 'a' || dayF == 's' && dayS == 'u')
break;
if(dayF == 'M' && dayS == 'o' || dayF == 'T' && dayS == 'u' || dayF == 'W' && dayS == 'e' || dayF == 'T' && dayS == 'r' || dayF == 'F' && dayS == 'r' || dayF == 'S' && dayS == 'a' || dayF == 'S' && dayS == 'u')
break;
if(dayF == 'm' && dayS == 'O' || dayF == 't' && dayS == 'U' || dayF == 'w' && dayS == 'E' || dayF == 't' && dayS == 'R' || dayF == 'f' && dayS == 'R' || dayF == 's' && dayS == 'A' || dayF == 's' && dayS == 'U')
break;
}
cout << "In format hour - minute, enter the time of the call \n ";
cin >> timeofcall;
cout << "How long, in minutes, did the call last? \n";
cin >> lengthofcall;
return 0;
}
i recommend you build subroutines to help you out. it'll split the logic into separate parts to make it easier to focus as well as debug. the highlighted code has no place in your main function for example. split that into a separate function.
as for the time itself, i recommend having a function split the duration into separate components, where each component has a single billing rate.
/edit: take back the last part. i thought the bill was going to be split, but it looks like it only depends on when the call started. so you should have a function that determines which of those 3 slots it fits into.
This post was edited by carteblanche on Oct 4 2013 10:28pm