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

A specialty coffee store has drive-up window service between 5:00am and 11:00pm.

ID: 3630645 • 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)

Formatting Specifications

name, section#, and assignment# should be displayed before the table

leave at least 1 blank line between name, sec#, assign# and start of the table

each column of the table should have an appropriate heading

receipt #s should be right justified

arrival and departure times must be displayed using military time (hh:mm) and should be aligned in their columns

right justify transaction times

leave at least 1 blank line between the last entry in the table and the statements displaying total minutes, # of transactions, and average
Input File Assumptions

Each line in the data file will start with a valid, integer (>=0). Maximum value will be 9999.

Arrival time and departure time will be present on each line that starts with a non-zero receipt #.
Times will be valid and within the operating hours for the shop. The hour and minutes will be separated by a colon. Each time will be followed by am or pm.
Arrival time will be <= departure time.
Each of the 3 input values will be separated by at least one blank space.
The sentinel (0) will be present in the file.

Sample terminal session:
[lee@bobby keys_fa11]$ more hw06data
1001 7:21am 7:28am
123 4:30pm 4:47pm
5532 11:58am 12:09pm
0
[lee@bobby keys_fa11]$ g++ hw06.cpp
[lee@bobby keys_fa11]$ ./a.out < hw06data
Lee Misch Section #100_ Assignment #6

RECEIPT # ARRIVAL DEPARTURE TRANS TIME
1001 07:21 07:28 7
123 16:30 16:47 17
5532 11:58 12:09 11

Total time of transactions: 35 minutes.
Total # of transactions: 3
Average length of transaction: 11.667


IMPORTANT: Make sure you test your program adequately. See Generating Test Data Handout for a testing strategy.

When your program is running properly, add comments (above the preprocessor directive) that

state your name, section #, and assignment # (3 pts)

provide a brief description of what the program will do (be specific about what output will be generated) (12 pts)
for each major constant or variable that you declare, provide a brief comment describing what the variable represents (5 pts)
use meaningful names for your constants and variables

constants must be declared before the start of the main function - description should be placed near the declaration

variables must be declared inside the main function - description should be placed near the declaration

After adding comments always recompile and run your program.
Make sure your program includes the appropriate documentation.When your program is complete, has been documented, and tested, submit your program.

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 cout
Hire Me For All Your Tutoring Needs
Integrity-first tutoring: clear explanations, guidance, and feedback.
Drop an Email at
drjack9650@gmail.com
Chat Now And Get Quote