Quote:Write a program that computes the cost of a long-distance call and the total cost of all the calls made. The cost of the call is determined according to the following rate schedule:
Any call started between 8:00 a.m. (0800 hours) and 6:00 p.m. (1800 hours)
during the weekdays is billed at the rate of $0.20 per minute.
Any call started after 6:00 p.m. (1800 hours) and 11:00 p.m. (2300 hours)
during the weekdays is billed at the rate of $ 0.15 per minute.
Any call made during the weekend (Saturday and Sunday) and after 11:00 p.m. and before 8:00 a.m. every day is billed at the rate of $0.10 per minute.
The input will consist of the day (weekday or weekend), the time call started, and the length of the call in minutes. The time is to be input in 24-hour notation. The day of the week will be read as a string. The time and the length will be integer values. You do not have to worry about a call going from one rate to another. For example if the call started at 745 and the length of the call is 30 minutes, your entire call will be calculated at the rate of the time call started. Declare all the rates as named constants in your program.
Use loops and if statements in your program. Do not forget to include the string library. Create your own test data to test all the if statements.
Sample output of the program
Enter the day weekday or weekend weekday
Enter the time the call started 900
Enter the length of the call 20
weekday 20 minute call started at 900 hrs will cost $ 4.00
Do you have another y/n y
Enter the day weekday or weekend weekend
Enter the time the call started 100
Enter the length of the call 20
weekend 20 minute call started at 100 hrs will cost $ 2.00
Do you have another y/n n
Total cost $
Thats a sloppy copy and paste, but thats everything you need to know. Now I've done a majority of the work and I just have a few questions about it. For one, my terminal won't compile (not because its wrong but because its telling me the command doesn't exist). So I need to know what I did wrong, how I can fix it, and any other advice. Thank you in advance. The code is as follows:
#include <iostream>using namespace stdint main(){string weekday;string weekend;string day = weekday || weekend;int time;int length;cout << "Enter the day weekday or weekend \n";cin >> day;cout << "Enter the time the call started \n";cin >> time;cout << "Enter the length of the call \n";cin >> length;int rate;if (time > 0800 > 1800; day = weekday;) { rate = 0.20; }if else (time > 1800 > 2300; day = weekday;) { rate = 0.15; }if else (time > 2300 > 0800; day = weekend;) { rate = 0.10; }int cost = rate*length;cout << day; << length; << "minute call started at "; << time; << "hrs will cost $"; << cost; << endl;//Do you have another y/n?//cout << "Total cost $ ";}
Mod Edit by Evil Steve: Changed code tag to a quote to fix forum formatting.