Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

// Chapter 5 homework solution: Sales #include #include using namespace std; // Function Prototype double caltotalSales(double, double); double calAverage(double, int); int main() { int years,

// Chapter 5 homework solution: Sales #include  #include  using namespace std; // Function Prototype double caltotalSales(double, double); double calAverage(double, int); int main() { int years, // The number of years totalQuarters; // The number of quarters double sales, totalSales = 0, // The total sales for all quarters average; // The average quarterly sales // Get the number of years. cout << "This program will calculate average sales over a " << "period of years. How many years do you wish to average? "; cin >> years; // Validate the number of years. while (years < 1) { cout << "Years must be at least one. Please re-enter: "; cin >> years; } for (int yearNumber = 1; yearNumber <= years; yearNumber++) { cout << " Year " << yearNumber << endl; // Get the sales amount for each quarter. for (int quarter = 1; quarter <= 4; quarter++) { cout << "sales amount for quarter " << setw(2) << quarter << "? "; cin >> sales; // Validate the sales amount. while (sales < 0) { cout << "Sales amount must be zero or greater. "; cout << "Sales amount for month " << quarter << "? "; cin >> sales; } // Get the total sales from funtion totalSales = caltotalSales(totalSales, sales); } } // Calculate the total number of quarters. totalQuarters = years * 4; // Get the average from average function average = calAverage(totalSales, totalQuarters); // Calculate the average sales amount. // Display the total sales amount for the period. cout << fixed << showpoint << setprecision(2); cout << " Over a period of " << totalQuarters << " quarters, " << totalSales <REWRITE THIS CODE USING ARRAY 

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

Database And Expert Systems Applications 33rd International Conference Dexa 2022 Vienna Austria August 22 24 2022 Proceedings Part 2 Lncs 13427

Authors: Christine Strauss ,Alfredo Cuzzocrea ,Gabriele Kotsis ,A Min Tjoa ,Ismail Khalil

1st Edition

3031124251, 978-3031124259

More Books

Students also viewed these Databases questions

Question

1. Select the job or jobs to be analyzed.

Answered: 1 week ago