Question
Hi, I want to add the total cost of all the calls at the end how can I do it. Basically like this... My code
Hi,
I want to add the total cost of all the calls at the end how can I do it. Basically like this... My code is written below, let me know how to make a report like this at the end, thank you.
Your program should generate a report like this:
Your program should generate a report like this:
Day Time Duration Cost
Mo 13:30 16 $6.40
Mo 8:15 35 $14.00
Tu 7:50 20 $6.50
We 17:45 30 $9.75
Th 8:00 45 $18.00
Su 23:50 30 $6.50
Total $61.15
#include
using namespace std;
int main() { int minutes, startTime; char ch; string Day; double cost, rate; cout << fixed << showpoint << setprecision (2); do { cout << "Enter start time of the call (For example, 2:30 = 2330): "; cin >> startTime; while(startTime < 0 || startTime >= 2400) { cout << " Invalid time."; cout << "Enter start time of the call(For example, 2:30 = 2330): "; cin >> startTime; } cout << "Enter how long call was in minutes: "; cin >> minutes; cout << "Enter the day of the week (write first two letters of the day for example Monday is Mo):"; cin >> Day; if(Day == "Mo"|| Day == "MONDAY" || Day == "Tu" || Day == "TUESDAY" || Day =="We" || Day == "WEDNESDAY" || Day =="Th" || Day == "thursday" || Day == "Fr" || Day =="FRIDAY") { if (startTime >= 800 && startTime <= 1800) rate = 0.4; else rate = 0.25; cost = minutes * rate; cout << " Rate for the call was " << "$" << rate << " a minute"<< endl << "Your total cost: " << "$" << cost << endl; } else if(Day =="Sa" || Day =="SATURDAY" || Day =="Su" || Day =="SUNDAY") { rate = 0.15; cost = minutes * rate; cout << "/The rate for your call was " << "$"<< rate << " a minute"<< endl << "Your total cost is: " << "$" << cost; } else cout << " Invalid."; cout << endl << " Would you like to calculate your bill again? (y/n): "; cin >> ch; cout << endl << endl;
} while( ch =='Y' || ch == 'y'); cout << " Thank you, please come again. "; return 0; }
Step by Step Solution
There are 3 Steps involved in it
Step: 1
Get Instant Access to Expert-Tailored Solutions
See step-by-step solutions with expert insights and AI powered tools for academic success
Step: 2
Step: 3
Ace Your Homework with AI
Get the answers you need in no time with our AI-driven, step-by-step assistance
Get Started