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

Question 23 Complete the programs by adding the lines or parts of lines that hav

ID: 3920064 • Letter: Q

Question

Question 23

Complete the programs by adding the lines or parts of lines that have been omitted, or show output.

<<<<<<<<<<<<<<<<<<<<<<<<    >>>>>>>>>>>>>>>>>>>>>>>>>

Corporate Sales Data Output

#include <iostream>

#include <fstream>

using namespace std;

// Constant for array size

const int SIZE = 12;

// Declaration of the Division structure

struct Division

{

Blank 1 // Division name A. Add code in this box

Blank 2 // Quarter number B. Add code in this box

Blank 3 // Quarterly sales C. Add code in this box

};

int main()

{

   // File stream object for the corp.dat file

   fstream file("corp.dat", ios::out | ios::binary);

  

   Division east, west, north, south;           // Division structure variables for each division

  

   int qtr;                                                             // Loop counter for each quarter             

   // Assign the division names to the division structure variables.

   strcpy_s(east.divName, "East");

   strcpy_s(west.divName, "West");

   strcpy_s(north.divName, "North");

   strcpy_s(south.divName, "South");

   //Get sales data for East division

   cout << "Enter the quarterly sales for the East Divison: ";

   for (qtr = 1; qtr <= 4; qtr++)

   {

         east.quarter = qtr;

         cout << " Quarter " << qtr << ": ";

         cin >> east.sales;

         file.write(reinterpret_cast (&east), sizeof(east));

   }

   //Get sales data for West division

   cout << "Enter the quarterly sales for the West Divison: ";

   for (qtr = 1; qtr <= 4; qtr++)

   {

Blank 4 D. Add code in this box

Blank 5 E. Add code in this box

Blank 6 F. Add code in this box

Blank 7 G. Add code in this box

   }

   //Get sales data for North division

   cout << "Enter the quarterly sales for the North Divison: ";

Blank 8 H. Add code in this line

{

Blank 9 I. Add code in this box

Blank 10 J. Add code in this line

Blank 11 K. Add code in this box

Blank 12 L. Add code in this box

   }

   //Get sales data for South division

   cout << "Enter the quarterly sales for the South Divison: ";

   for (qtr = 1; qtr <= 4; qtr++)

   {

         south.quarter = qtr;

         cout << " Quarter " << qtr << ": ";

         cin >> south.sales;

         file.write(reinterpret_cast (&south), sizeof(south));

   }

   // Close the file.

Blank 13 M. Add code in this box

   return 0;

Explanation / Answer

Please find the filled code below:

#include <iostream>

#include <fstream>

#include<string>

using namespace std;

// Constant for array size

const int SIZE = 12;

// Declaration of the Division structure

struct Division

{

string divName;//Blank 1 // Division name A. Add code in this box

int quarter;//Blank 2 // Quarter number B. Add code in this box

double sales;//Blank 3 // Quarterly sales C. Add code in this box

};

int main()

{

// File stream object for the corp.dat file

fstream file("corp.dat", ios::out | ios::binary);

Division east, west, north, south; // Division structure variables for each division

int qtr; // Loop counter for each quarter

// Assign the division names to the division structure variables.

strcpy_s(east.divName, "East");

strcpy_s(west.divName, "West");

strcpy_s(north.divName, "North");

strcpy_s(south.divName, "South");

//Get sales data for East division

cout << "Enter the quarterly sales for the East Divison: ";

for (qtr = 1; qtr <= 4; qtr++)

{

east.quarter = qtr;

cout << " Quarter " << qtr << ": ";

cin >> east.sales;

file.write(reinterpret_cast (&east), sizeof(east));

}

//Get sales data for West division

cout << "Enter the quarterly sales for the West Divison: ";

for (qtr = 1; qtr <= 4; qtr++)

{

west.quarter = qtr;

cout << " Quarter " << qtr << ": ";

cin >> west.sales;

file.write(reinterpret_cast (&west), sizeof(west));

/*Blank 4 D. Add code in this box

Blank 5 E. Add code in this box

Blank 6 F. Add code in this box

Blank 7 G. Add code in this box*/

}

//Get sales data for North division

cout << "Enter the quarterly sales for the North Divison: ";

for (qtr = 1; qtr <= 4; qtr++)//Blank 8 H. Add code in this line

{

north.quarter = qtr;

cout << " Quarter " << qtr << ": ";

cin >> north.sales;

file.write(reinterpret_cast (&north), sizeof(north));

/*Blank 9 I. Add code in this box

Blank 10 J. Add code in this line

Blank 11 K. Add code in this box

Blank 12 L. Add code in this box*/

}

//Get sales data for South division

cout << "Enter the quarterly sales for the South Divison: ";

for (qtr = 1; qtr <= 4; qtr++)

{

south.quarter = qtr;

cout << " Quarter " << qtr << ": ";

cin >> south.sales;

file.write(reinterpret_cast (&south), sizeof(south));

}

// Close the file.

file.close();//Blank 13 M. Add code in this box

return 0;

}

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