A specialty coffee store has drive-up window service between 5:00am and 11:00pm.
ID: 3631180 • Letter: A
Question
A specialty coffee store has drive-up window service between 5:00am and 11:00pm. In an effort to determine information about customer wait times, employees have been asked to keep accurate records about customer transactions.As a result, you have a file that contains several lines of data. Each line contains a receipt # (an integer that identifies a customer transaction, max 4 digits), the time when the customer arrived, and the time the customer left. All times are presented in 12-hour clock format. For example: 6:00am, 3:20pm, 12:07pm. A receipt # of 0 will be used as a sentinel to indicate the end of the input data.
Sample input file:
1001 7:21am 7:28am
123 4:30pm 4:47pm
5532 11:58am 12:09pm
0
Design a C++ program that will read the input from the data file using Linux redirection and do the following:
display your name, section #, and the assignment #
display a table with 4 columns, Receipt #, Arrival Time, Departure Time, Length of Transaction
place the appropriate information in each column for the transactions read from the data file
all times must be displayed in military format (hh:mm) - for example: 06:00am is 06:00, 3:20pm is 15:20, 12:07pm is 12:07
length of transaction time should be displayed in minutes
after all data has been read and the table generated, display the total minutes for all transactions and how many transactions were read from the file
compute and display the average length of a transaction (3 digits to the right of the decimal)
Explanation / Answer
#include #include #include #include #include using namespace std; //coffee of type structure struct coffee { //structure variable int id; string stime; string etime; }; //readFile prototype int readFile(fstream&,coffee []); int main() { fstream fin; //Open file in read mode fin.open("file.txt",ios::in); //structur of type 3 objects coffee c[3]; int i=0,totalhours=0,totalminutes=0; //get number of records read from file int count=readFile(fin,c); //if i less than count coutRelated Questions
Hire Me For All Your Tutoring Needs
Integrity-first tutoring: clear explanations, guidance, and feedback.
Drop an Email at
drjack9650@gmail.com
drjack9650@gmail.com
Navigate
Integrity-first tutoring: explanations and feedback only — we do not complete graded work. Learn more.