Question: C++ help. Write a program named Lab5b.cpp . This program reads expense data from a file in a predefined format and produces an expense report.
C++ help.
Write a program named Lab5b.cpp. This program reads expense data from a file in a predefined format and produces an expense report.
Follow the steps described here to complete the program.
Collecting Data From The Data File
Define a named constant for the size of the arrays. For example, const int NUM_DAYS = 7;
Define an array of strings for the days and an array of doubles for the expenses using the named constant as the array size. Initialize the array of doubles with 0.0, not 0. Each day in the array of days corresponds to the expense in the same position in the array of expenses.
Check. The arrays have been defined using meaningful identifiers.
Check. The arrays have been defined using the named constant as the array size.
Check. The array of doubles have been initialized with 0.0.
Define a named string constant for the file expenses.txt which was created by lab3a. You may also create the expense file by hand using a text editor.
Open the file using the named string constant.
Read the data from the expense file into the arrays. The code for reading the expense records should not assume there are exactly seven records in the file. Use a counter variable to keep track of the number of records received from the file. Other than reading and counting the number of expense records, don't do any data processing and reporting at this step.
Close the file.
Check. The number 7 is not used in any form in the process of reading the file.
Check. No calculation for total, average, and largest at this step.
Check. No reporting at this step.
Check. File is closed.
Process Data
Process the data in the arrays. Calculate the total, average, and largest expense.
Create Report
Generate the expenses report as shown below.
Check. Make sure you have a C++ comment above each section you have accomplished.
Check. The report is identical as shown above.
Check. Submit both Lab5b.cpp and expenses.txt.
Rubric
My Weekly Expense Report Sunday Monday Tuesday Wednesday Thursday Friday Saturday 45.25 49.38 12.75 123.50 8.25 19.95 145.70 Total of expenses: Average of expenses: Largest expenses: 404.78 57.83 145.70Step by Step Solution
There are 3 Steps involved in it
Get step-by-step solutions from verified subject matter experts
