Question

Question 23 Complete the programs by adding the lines or parts of lines that have been...

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:\n";

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

   {

         east.quarter = qtr;

         cout << "\tQuarter " << 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:\n";

   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:\n";

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:\n";

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

   {

         south.quarter = qtr;

         cout << "\tQuarter " << qtr << ": ";

         cin >> south.sales;

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

   }

   // Close the file.

Blank 13 M. Add code in this box

   return 0;

0 0
Add a comment Improve this question Transcribed image text
Answer #1

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:\n";

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

{

east.quarter = qtr;

cout << "\tQuarter " << 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:\n";

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

{

west.quarter = qtr;

cout << "\tQuarter " << 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:\n";

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

{

north.quarter = qtr;

cout << "\tQuarter " << 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:\n";

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

{

south.quarter = qtr;

cout << "\tQuarter " << 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;

}

Add a comment
Know the answer?
Add Answer to:
Question 23 Complete the programs by adding the lines or parts of lines that have been...
Your Answer:

Post as a guest

Your Name:

What's your source?

Earn Coins

Coins can be redeemed for fabulous gifts.

Not the answer you're looking for? Ask your own homework help question. Our experts will answer your question WITHIN MINUTES for Free.
Similar Homework Help Questions
  • Code in C++: Please help me fix the error in function: void write_account(); //function to write...

    Code in C++: Please help me fix the error in function: void write_account(); //function to write record in binary file (NOTE: I able to store data to a txt file but however the data get error when I try to add on data the second time) void display_all(); //function to display all account details (NOTE: This function is to display all the info that save account.txt which is ID, Name, and Type) void modify_account(int); //function to modify record of file...

  • Write a C++ program that uses a structure to store the following inventory information in a...

    Write a C++ program that uses a structure to store the following inventory information in a file: ⦁   Item description, Quantity on hand, Wholesale cost, Retail cost, and Date added to inventory. ⦁   Use a char array for item description and date. ⦁   The program should have a menu that allows the user to perform the following tasks: i.   Add a new record at the end of the file. ii.   Display any record in the file. iii.   Change any record...

  • guys need help please im super lost anyone save me do programming exercise top_div_array.cpp: Winning Division...

    guys need help please im super lost anyone save me do programming exercise top_div_array.cpp: Winning Division app (top_div.cpp) revisited to use arrays This is the same program done last week but using and passing arrays instead of individual variables. Start with the following file / cODE BELOW: // Name: top_div_array.cpp // Description: // This app inputs sales for four regional division and displays the highest. // To accomplish this, use two arrays of equal length - one for sales and...

  • C++ and Using Microsoft Visual Studio. Write 2 programs: One program will use a structure to...

    C++ and Using Microsoft Visual Studio. Write 2 programs: One program will use a structure to store the following data on a company division: Division Name (East, West, North, and South) Quarter (1, 2, 3, or 4) Quarterly Sales The user should be asked for the four quarters' sales figures for the East, West, North, and South divisions. The data for each quarter for each division should be written to a file. The second program will read the data written...

  • [C++] Please help to understand why this code need to have "void calcSales(CorpData &);" and "void...

    [C++] Please help to understand why this code need to have "void calcSales(CorpData &);" and "void displayDivInfo(CorpData);". Thanks! ------------------------------------------------------------------------------------------------------------------------------------------------------------------------------ #include <iostream> #include <string> using namespace std; struct CorpData { string diviName; double firstQua, secondQua, thirdQua, fourthQua, annualSales, quaAvg;    CorpData(string d, double fq, double sq, double tq, double frq) { diviName = d; firstQua = fq; secondQua = sq; thirdQua = tq; fourthQua = frq; } }; void calcSales(CorpData &); void displayDivInfo(CorpData); int main() {    CorpData West("West", 10000, 20000,...

  • 1. What would be the output of the following lines of code: int num = 2;...

    1. What would be the output of the following lines of code: int num = 2; switch(num){ case 1: cout << "1"; case 2: cout << "2"; case 3: cout << "3"; case 4: cout << "4"; } 2. What would be the output of the following code: char op = '*'; switch(op){ case '+': cout << "Addition"; break; case '-': cout << "Subtraction"; break; case '/': cout << "Division"; break; default: cout << "Invalid"; } 3. What would be...

  • I need to add something to this C++ program.Additionally I want it to remove 10 words...

    I need to add something to this C++ program.Additionally I want it to remove 10 words from the printing list (Ancient,Europe,Asia,America,North,South,West ,East,Arctica,Greenland) #include <iostream> #include <map> #include <string> #include <cctype> #include <fstream> #include <iomanip> using namespace std; void addWord(map<std::string,int> &words,string s); void readFile(string infile,map<std::string,int> &words); void display(map<std::string,int> words);    int main() { // Declaring variables std::map<std::string,int> words;       //defines an input stream for the data file ifstream dataIn;    string infile; cout<<"Please enter a File Name :"; cin>>infile; readFile(infile,words);...

  • CProgramming using Dev C ++ #include <stdio.h> PLEASE NO math.h Corporate Sales Data Report Write a...

    CProgramming using Dev C ++ #include <stdio.h> PLEASE NO math.h Corporate Sales Data Report Write a program that read creates a structure for a company's divisions. The structure should have: Division name (North, South, East, West, and Central) Quarter (1, 2, 3, or 4) Quarterly sales · Your job is to write a program that will create a two-dimensional array of 5 rows (divisions) and 4 columns (quarters). The program should ask the user to enter in all four quarters...

  • Directions: Create a structure that contains the following data: DivisionName First-QuarterSales Second Quarter Sales Third Quarter...

    Directions: Create a structure that contains the following data: DivisionName First-QuarterSales Second Quarter Sales Third Quarter Sales Fourth Quarter Sales Total Sales Average Sales Create an enumerated data type of {North,South,East,West} Create an array of this structure with one instance for each enumerated data type listed above. Write a C++ program that will create a menu driven program with the following options: Menu Options: A) Add Data B) Compute Total Sales and Avg Sales C) Display Data D) Division Highest...

  • I need to get this two last parts of my project done by tonight. If you...

    I need to get this two last parts of my project done by tonight. If you see something wrong with the current code feel free to fix it. Thank you! Project 3 Description In this project, use project 1 and 2 as a starting point and complete the following tasks. Create a C++ project for a daycare. In this project, create a class called child which is defined as follows: private members: string First name string Last name integer Child...

ADVERTISEMENT
Free Homework Help App
Download From Google Play
Scan Your Homework
to Get Instant Free Answers
Need Online Homework Help?
Ask a Question
Get Answers For Free
Most questions answered within 3 hours.
ADVERTISEMENT
ADVERTISEMENT