Computer Science C++ Convert following program to use a loop and step through input the data for each division , also recive data from an input file that contains 4 row (for each division) and 4 column for each quarter sales //Name: //Date: //Problem statemnt: Corporate Sales Data Page 659 Gaddis #include #include #include using namespace std;

Computer Networking: A Top-Down Approach (7th Edition)
7th Edition
ISBN:9780133594140
Author:James Kurose, Keith Ross
Publisher:James Kurose, Keith Ross
Chapter1: Computer Networks And The Internet
Section: Chapter Questions
Problem R1RQ: What is the difference between a host and an end system? List several different types of end...
icon
Related questions
Question

Computer Science

C++

Convert following program to use a loop and step through input the data for each division , also recive data from an input file that contains 4 row

(for each division) and 4 column for each quarter sales

//Name:
//Date:
//Problem statemnt: Corporate Sales Data Page 659 Gaddis

#include
#include
#include
using namespace std;

// Declaration of the Division structure.
struct Division
{
   string name;            // Division name
   double quarter1;        // First quarter sales
   double quarter2;        // Second quarter sales
   double quarter3;        // Third quarter sales
   double quarter4;        // Fourth quarter sales
   double annualSales;     // Annual sales
   double averageQtrSales; // Average quarterly sales
};

int main()
{
   //================= Create structure variables for each division. ===================
   Division east, west, north, south;

   //============= Store the names of the divisions. ===================================
   east.name = "East";
   west.name = "West";
   north.name = "North";
   south.name = "South";
   //---------------------------------EAST DIVISION --------------------------------
   //=================== Get sales data for East division ===============================
   cout << "Enter the quarterly sales for the East Divison:\n";
   cout << "First quarter: "<    cin >> east.quarter1;
   cout << "Second quarter: " << endl;
   cin >> east.quarter2;
   cout << "Third quarter: " << endl;
   cin >> east.quarter3;
   cout << "Fourth quarter: " << endl;
   cin >> east.quarter4;

   //====== Calculate the annual sales & average sales for the east division. ============
   east.annualSales = east.quarter1 + east.quarter2 + east.quarter3 + east.quarter4;
   east.averageQtrSales = east.annualSales / 4.0;
   //-----------------------------------West DIVISION -------------------------------------------------
   //================= Get sales data for West division =======================
   cout << "Enter the quarterly sales for the West Divison:\n";
   cout << "First quarter: " << endl;
   cin >> west.quarter1;
   cout << "Second quarter: " << endl;
   cin >> west.quarter2;
   cout << "Third quarter: " << endl;
   cin >> west.quarter3;
   cout << "Fourth quarter: " << endl;
   cin >> west.quarter4;
  
   //====== Calculate the annual sales & average sales for the West division. ============
   west.annualSales = west.quarter1 + west.quarter2 + west.quarter3 + west.quarter4;
   west.averageQtrSales = west.annualSales / 4;
   //-----------------------------------North DIVISION -------------------------------------------------
   //==================== Get sales data for North division ============================
   cout << "Enter the quarterly sales for the North Divison:\n";
   cout << "First quarter: " << endl;
   cin >> north.quarter1;
   cout << "Second quarter: " << endl;
   cin >> north.quarter2;
   cout << "Third quarter: " << endl;
   cin >> north.quarter3;
   cout << "Fourth quarter: " << endl;
   cin >> north.quarter4;

   //======= Calculate the annual sales & average for NORTH the division.
   north.annualSales = north.quarter1 + north.quarter2 + north.quarter3 + north.quarter4;
   north.averageQtrSales = north.annualSales / 4;
   //-----------------------------------South DIVISION -------------------------------------------------
   //==================== Get sales data for South division =============================
   cout << "Enter the quarterly sales for the South Divison:\n";
   cout << "First quarter: " << endl;
   cin >> south.quarter1;
   cout << "Second quarter: " << endl;
   cin >> south.quarter2;
   cout << "Third quarter: " << endl;
   cin >> south.quarter3;
   cout << "Fourth quarter: " << endl;
   cin >> south.quarter4;

   //==== Calculate the annual & average sales for SOUTH the division. ===
   south.annualSales = south.quarter1 + south.quarter2 + south.quarter3 + south.quarter4;
   south.averageQtrSales = south.annualSales / 4;

   //============== Display Totals and Averages ====================
   cout << setprecision(2) << fixed << showpoint;
   cout << "             Total Annual Sales:    ===========> \n";
   cout << "\tEast Division: $" << east.annualSales << endl;
   cout << "\tWest Division: $" << west.annualSales << endl;
   cout << "\tNorth Division: $" << north.annualSales << endl;
   cout << "\tSouth Division: $" << south.annualSales << endl;
   cout << "             Average Quarterly Sales:    ========> \n";
   cout << "\tEast Division: $" << east.averageQtrSales << endl;
   cout << "\tWest Division: $" << west.averageQtrSales << endl;
   cout << "\tNorth Division: $" << north.averageQtrSales << endl;
   cout << "\tSouth Division: $" << south.averageQtrSales << endl;

   return 0;
}

 

Input file:

   East   West   North   South
Q1   90       85       78       89
Q2   95       75       88       90
Q3   78       98       65       89  
Q4   99       88       90       88

Expert Solution
steps

Step by step

Solved in 2 steps with 1 images

Blurred answer
Recommended textbooks for you
Computer Networking: A Top-Down Approach (7th Edi…
Computer Networking: A Top-Down Approach (7th Edi…
Computer Engineering
ISBN:
9780133594140
Author:
James Kurose, Keith Ross
Publisher:
PEARSON
Computer Organization and Design MIPS Edition, Fi…
Computer Organization and Design MIPS Edition, Fi…
Computer Engineering
ISBN:
9780124077263
Author:
David A. Patterson, John L. Hennessy
Publisher:
Elsevier Science
Network+ Guide to Networks (MindTap Course List)
Network+ Guide to Networks (MindTap Course List)
Computer Engineering
ISBN:
9781337569330
Author:
Jill West, Tamara Dean, Jean Andrews
Publisher:
Cengage Learning
Concepts of Database Management
Concepts of Database Management
Computer Engineering
ISBN:
9781337093422
Author:
Joy L. Starks, Philip J. Pratt, Mary Z. Last
Publisher:
Cengage Learning
Prelude to Programming
Prelude to Programming
Computer Engineering
ISBN:
9780133750423
Author:
VENIT, Stewart
Publisher:
Pearson Education
Sc Business Data Communications and Networking, T…
Sc Business Data Communications and Networking, T…
Computer Engineering
ISBN:
9781119368830
Author:
FITZGERALD
Publisher:
WILEY