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

This C++ program will use a structure to hold the data for each division of a co

ID: 3749868 • Letter: T

Question

This C++ program will use a structure to hold the data for each division of a corporation.

The structure will keep the following data:

Name of division (string)

Sales total for quarter 1 (double)

Sales total for quarter 2 (double)

Sales total for quarter 3 (double)

Sales total for quarter 4 (double)

The program will ask the user for the inputs needed to populate the structure. Then display the data for each instance of the structure.

Complete the code below to complete the program and provide a /*multi-line psedudocode*/ for the program.

Explanation / Answer

The pseudocode is mentioned as comments before each function.
Please comment if you need more light on pseudocode.

============================================================================

#include <iostream>

#include <string>

#include <iomanip>

using namespace std;

/* Declare a struct with string type variable to hold name of the division. 4 double type variables to hold the sales for 4 quarters

*/

struct Division

{

string name;

double quarter1;

double quarter2;

double quarter3;

double quarter4;

};

void GetDivisionSales(Division& div); //method declaration

void DisplayDivision(Division div);

int main()

{

Division east, west, north, south; //Create 4 instances of Division type

east.name = "East"; //assign name to all the 4 Divisions

west.name = "West";

north.name = "North";

south.name = "South";

/* GetDivisionSales will get sales for all 4 quarters into the respective struct */

GetDivisionSales(east);

GetDivisionSales(west);

GetDivisionSales(north);

GetDivisionSales(south);

/* DisplayDivision will display details of a division in properly formatted manner*/

DisplayDivision(east);

DisplayDivision(west);

DisplayDivision(north);

DisplayDivision(south);

return 0;

}

/*Implementation of GetDivisionSales , stores sales for all 4 quarters corresponding to a Division*/

void GetDivisionSales(Division& div)

{

cout<<" Enter the quarter1 sales for "<<div.name<<" division ";

cin>>div.quarter1;

cout<<"Enter the quarter2 sales for "<<div.name<<" division ";

cin>>div.quarter2;

cout<<"Enter the quarter3 sales for "<<div.name<<" division ";

cin>>div.quarter3;

cout<<"Enter the quarter4 sales for "<<div.name<<" division ";

cin>>div.quarter4;

}

void DisplayDivision(Division div)

{

cout << " Sales amount for " << div.name << " Division" << endl;

cout << setw(20) << div.quarter1 << endl;

cout << setw(20) << div.quarter2 << endl;

cout << setw(20) << div.quarter3 << endl;

cout << setw(20) << div.quarter4 << endl;

cout << "Total Sales " << div.quarter1 + div.quarter2

+ div.quarter3 + div.quarter4 << endl;

}

=========================================================================

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