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

in C++ with this criteria How well is the program structured? For example, are t

ID: 3689474 • Letter: I

Question

in C++

with this criteria

How well is the program structured? For example, are there divisions into smaller tasks/functions?

How well is the program documented? For example, how well have you described the purpose of each task/function and the expected result?

How well is the program formatted? Have you written it according to the programming styles described in the textbook to help readability? Have you used proper naming conventions for the identifiers?

How well does the program satisfy the requirements? For example, have you completed all required parts?

How does the program execute?

The function declaration is as follows: //********************************************************************************************* // Function Name: expenseReport // // The function computes the average of the expenses stored in the input // array parameter and displays a report of the expenses to the screen. // // Parameters: // expenses - An array of double numbers // count - An integer representing the number of expenses // Returns: // void //********************************************************************************************* Write a complete program to use this function. You need to use an array of double numbers and initialize the array with the expense amounts. The report should have all numbers aligned on the decimal points. The report should look exactly as follows:

My Expense Report
              =====================
                        1             45.25
                        2             49.38
                        3             12.75
                        4           123.50
                        5               8.25
                        6             19.95
                        7           145.70
Total           404.78
Average    57.83

Explanation / Answer

#include <iostream>
#include <iomanip>

using namespace std;

void expenseReport(double expenses[],int num){
   double count;
   int i=0;

   for(i=0;i<num;++i){
       count += expenses[i];
   }

   cout<<"Total "<<count<<endl;
   cout<<"Average "<<setprecision(4)<<count/num<<endl;

}

int main(){
   double expenses[7]={45.25,49.38,12.75,123.50,8.25,19.95,145.70};

   cout<<"My Expense Report"<<endl;
   cout<<" -----------------------------"<<endl;
   cout<<" -----------------------------"<<endl;

   for(int i=0;i<7;++i)
       cout<<" "<<i+1<<" "<<expenses[i]<<endl;

   expenseReport(expenses,7);
   return 0;
}