Question

In: Computer Science

A) csc 401 c++ Write a class CorpData to store the following information on a company...

A) csc 401 c++

Write a class CorpData to store the following information on a company division:

a. Division name (such as East, West, North, or South)

b. First quarter sales c. Second quarter sales d. Third quarter sales e. Fourth quarter sales Include a constructor that allows the division name and four quarterly sales amounts to be specified at the time a CorpData object is created. The program should create four CorpData objects, each representing one of the following corporate divisions: East, West, North, and South. These objects should be passed one at a time, to a function that computes the division's annual sales total and quarterly average, and displays these along with the division name.

Solutions

Expert Solution

Hi,

Hope you doing fine. I have coded the above question in C++ keeping all the conditions in mind. The logic of the code is pretty straight forward and it is clearly explained using comments that have been highlighted in bold, Also find the coode snippet and the sample output to get a clearer picture.

Program:

#include<iostream>

using namespace std;

//declaring class
class CorpData{
   //declaring class attributes
   public:
       string name;
       double firstquarter;
       double secondquarter;
       double thirdquarter;
       double fourthquarter;
  
   //creating parameterized constructor  
   public:
       CorpData(string division,double first,double second,double third,double fourth){
           //assigning values to each attribute of class.
           name=division;
           firstquarter=first;
           secondquarter=second;
           thirdquarter=third;
           fourthquarter=fourth;
       }
      
};

//function to display the division name, total sales and average sales per quarter
void displaySales(CorpData data)
{
   double total,avg;
   //calculating totaal sales
   total=data.firstquarter+data.secondquarter+data.thirdquarter+data.fourthquarter;
   //calculating average quarterly sale
   avg=total/4;
   //printing output
   cout << "Division name: "<<data.name<<"\n";
   cout <<"Annual sales total: "<<total<<"\n";
   cout <<"Quarterly average: "<<avg<<"\n\n";
}

//main function
int main()
{
   //creating 4 object sof class CorpData using the parameterized constructor
   CorpData obj1("East",100,200,300,400);
   CorpData obj2("West",150,20,30,40);
   CorpData obj3("North",85,250,100,125);
   CorpData obj4("South",500,200,500,400);
   //calling displaySales() for each object to display results
   displaySales(obj1);
   displaySales(obj2);
   displaySales(obj3);
   displaySales(obj4);
}

Executable code snippet:

Output:


Related Solutions

[ Write in C not C++] 1. Define a C structure Covid19Info to store the information...
[ Write in C not C++] 1. Define a C structure Covid19Info to store the information of COVID 19 cases of countries around the world. It keeps the name of the country, number of COVID 19 cases, number of deaths, current test positive rate, etc. After defining the structure, declare a variable of Covid19Info type with some initial values for Bangladesh. [8]
Write a program that does the following in C++ 1 ) Write the following store data...
Write a program that does the following in C++ 1 ) Write the following store data to a file (should be in main) DC Tourism Expenses 100.20 Revenue 200.50 Maryland Tourism Expenses 150.33 Revenue 210.33 Virginia Tourism Expenses 140.00 Revenue 230.00 2 ) Print the following heading: (should be in heading function) Store name | Profit [Note: use setw to make sure all your columns line up properly] 3 ) Read the store data for one store (should be in...
Code in python: Write a class that implements a struct. In your struct store Student information...
Code in python: Write a class that implements a struct. In your struct store Student information such as name, netid, and gpa. Write a function that can access a student in a list of 5 structs by netid and print their name and gpa. Show that your function works by calling it.
Please write in C. This program will store roster and rating information for a soccer team....
Please write in C. This program will store roster and rating information for a soccer team. Coaches rate players during tryouts to ensure a balanced team. (1) Prompt the user to input five pairs of numbers: A player's jersey number (0 - 99) and the player's rating (1 - 9). Store the jersey numbers in one int array and the ratings in another int array. Output these arrays (i.e., output the roster). (3 pts) ex Enter player 1's jersey number:...
3. Write a C++ program that takes in the name of a store, and the following...
3. Write a C++ program that takes in the name of a store, and the following details for 4 employees working at the store; their first name, last name, number of hours they worked that week and how much they are paid per hour. Your program should output the name of the store, along with each employee's full name and how much they earned that week in the manner below. Monetary values should be format to 2 decimal places. Also...
The following information pertains to the Big Returns Fund: Cost Class "A" Class "B" Class "C"...
The following information pertains to the Big Returns Fund: Cost Class "A" Class "B" Class "C" Front-end load 5.57 0.00 0.00 Back-end load 0.00 5.34 0.89 Declining 1% per year First year only Management fee 0.80 0.80 0.80 12b-1 fee 0.30 0.60 0.80 For each share class, calculate (1) how much you would pay in initial commissions, (2) how much you would pay in back-end commissions if you sold after two years, (3) how much in value is lost to...
Write C++ program Consider the following SimpleString class: class simpleString {     public:          simpleString( );...
Write C++ program Consider the following SimpleString class: class simpleString {     public:          simpleString( );                                 // Default constructor          simpleString(int mVal );                    // Explicit value constructor          ~simpleString() { delete [ ] s;}          // Destructor void readString();                              // Read a simple string          void writeString() const;                    // Display a simple string char at(int pos) const;                       // Return character at (pos)          int getLength() const;                        // Return the string length          int getCapacity() const;...
Write a class Store which includes the attributes: store name and sales tax rate. Write another...
Write a class Store which includes the attributes: store name and sales tax rate. Write another class encapsulating a Book Store, which inherits from Store. A Book Store has the following additional attributes: how many books are sold every year and the average price per book. Code the constructor, accessors, mutators, toString and equals method of the super class Store and the subclass Book Store; In the Book Store class, also code a method returning the average taxes per year....
C++ Consider a class Movie that information about a movie. The class has the following attributes:...
C++ Consider a class Movie that information about a movie. The class has the following attributes: • The movie name • The MPAA rating (for example, G, PG, PG-13, R) • Array of size 5 called Ratings, each index will hold the following. [0] The number of people that have rated this movie as a 1 (Terrible) [1] The number of people that have rated this movie as a 2 (Bad) [2] The number of people that have rated this...
CSC MUST BE IN JAVA Design a program as per the following information using the accompanying...
CSC MUST BE IN JAVA Design a program as per the following information using the accompanying data file. Here is the datafile: sodaSalesB.dat Make sure the program compiles and that you include pseudo code. The assignment is worth 100 points.  (Lack of pseudo code will cost you 15pts) You have been asked to produce the report below. This report will tell the company how sales are going. You will read the file named sodasales.dat The values are the brand name, number...
ADVERTISEMENT
ADVERTISEMENT
ADVERTISEMENT