Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

Assignment: You are given an input file rates.txt with the following sample data: NewYork Delhi 1.99 2.00 0.45 NewYork London 1.50 1.75 0.35 Chicago Bombay

Assignment: You are given an input file rates.txt with the following sample data:

NewYork Delhi 1.99 2.00 0.45
NewYork London 1.50 1.75 0.35
Chicago Bombay 1.99 2.00 0.45
Chicago Bangkok 1.75 1.95 0.40

Each input line consists of the city from where the call is placed, the city to which the call is placed, the connection fee, amount for the first three minutes, and the amount for every additional minute after the first three minutes. Write a program that calculates the amount for a call placed for 15 minutes, 30 minutes, 45 minutes, and 1 hour (60 minutes), and stores it in an output file called a05output.txt. Format the output to two decimal places.

Requirements: You must use the function prototypes given below. If input file or output file does not open, output an error message and exit the program. You can add more functions if you like.

bool openInputFile(ifstream &, string filename);

bool openOutputFile(ofstream &, string filename);

void calculate(ifstream &, ofstream &);

Sample of your Output file

City from City to 15min 30min 45min 60min
NewYork Delhi 9.39 16.14 22.89 29.64
NewYork London 7.45 12.70 17.95 23.20
Chicago Bombay 9.39 16.14 22.89 29.64
Chicago Bangkok 8.50 14.50 20.50 26.50

Design Considerations Please use a while loop to read all lines of text from input file. Keep the input file in the same directory as your project.

Deliverables: You must use all the given function prototypes and not change them. You can add more functions if you like. Please upload your program source code (.cpp file) as usual. Be sure to comment your code as required, and to acknowledge any sources of help you may have received. Your header comments should include the identification of the assignment and your name. It should also include a comment indicating any sources of help you may have received. If there were none, the line should read:

// Sources: None.

Step by Step Solution

There are 3 Steps involved in it

Step: 1

blur-text-image

Get Instant Access to Expert-Tailored Solutions

See step-by-step solutions with expert insights and AI powered tools for academic success

Step: 2

blur-text-image

Step: 3

blur-text-image

Ace Your Homework with AI

Get the answers you need in no time with our AI-driven, step-by-step assistance

Get Started

Recommended Textbook for

Graph Databases New Opportunities For Connected Data

Authors: Ian Robinson, Jim Webber, Emil Eifrem

2nd Edition

1491930896, 978-1491930892

More Books

Students also viewed these Databases questions