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
  • 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...

  • 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...

  • 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...

  • 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,...

  • I need to complete a fill-in-the-blank C++ program using DEV C++, code needs to stick to program...

    ************************* proverb.txt. **********************************Now Is The Time fOr All GoOd Men to come to the aid of their Family*************************************************************************the sample run is as follows:Sample Run:The read position is currently at byte 0Enter an offset from the current position: 4The character read is IIf you would like to input another offset enter a Y yThe read position is currently at byte 5Enter an offset from the current position: 2The character read is TIf you would like to input another offset enter a...

  • 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);...

  • 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...

  • 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...

  • im writing a c++ code and getting stuck on two parts. The first part, when I...

    im writing a c++ code and getting stuck on two parts. The first part, when I go to write the customer order out to the file, it writes everything but the price out right. I'll get a weird number like 5.95828e-039 or nan. When I printout to the console it works fine so not sure what's wrong. Second After I write the order out to the file, I then have to go in and read the file and calculate the...

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
ADVERTISEMENT