Academic Integrity: tutoring, explanations, and feedback — we don’t complete graded work or submit on a student’s behalf.

Solve the telephone billing problem so the program will process an input file wi

ID: 3634259 • Letter: S

Question

Solve the telephone billing problem so the program will process an input file with multiple input lines in one run. the problem is:

A cellular telephone company offers two types of services: regular and premium. its rates vary, depending on the type of service:
Regular service: $10.00 fee. 50 minutes are free. charges for over 50 minutes are $0.20 per minute.
Premium service: $25.00 fee.
>for calls made from 6am to 6pm, the first 75 minutes are free; charges for more than 75 minutes are $0.10 per minute.
>for calls made from 6am to 6pm, the first 100 minutes are free; charges for more than 100 minutes are $0.05 per minute.
Note: fractions of a minute are charged at the rate of full minute. (use the ceiling function, ceil, in the header file "cmath")

Input will be from a file, and output will be to a file.
Input:
>for regular service, input (on one line) consists of service code (R or r), account number, and number of minutes.
>for premium service, input (on one line) consists of service code (P or p), account number, number of daytime minutes, and number of nighttime minutes.
>there are an unknown number of lines in the input file, so process lines until end-of-file is reached.
an example of possible input file content is:
R 4365 450.7
p 567321 25.8 100.75
P 000576 90 212.4
r 992345 49.9
x 4256 45.89 500
r 127111 -28.6
P67345 200 94

If there is an error in the input, identify the error in a message in the output file, remove any unread data remaining on the input file line which has the error, and go on to the process the next input file line.

Output:
Output the account number, type of service ("regular" or "premium"), the number of minutes the service was used, and the amount from the customer.

Explanation / Answer

#include #include #include using namespace std; int main() { string accountNumber = "",junk; char serviceCode = ' '; double numMinUsed = 0,over=0,minDay = 0, minNight = 0,bill =0.0,basic; bool ignore; ifstream in; ofstream out; in.open("input.txt"); //open file if(in.fail()) //is it ok? { coutaccountNumber; if (toupper(serviceCode) == 'P'){ in>>minDay; in>>minNight; if(minDay