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]
IN JAVA!   Write a class Store which includes the attributes: store name, city. Write another class...
IN JAVA!   Write a class Store which includes the attributes: store name, city. Write another class encapsulating an Art Gallery, which inherits from Store. An Art Gallery has the following additional attributes: how many paintings are sold every year and the number of artists submitting artwork. Code the constructor, accessors, mutators, toString and equals method of the super class Store. Code the constructor, accessors and mutators for the subclass Art Gallery. In the Art Gallery class, also code a method...
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:...
********************C# C# C#******************** Part A: Create a project with a Program class and write the following...
********************C# C# C#******************** Part A: Create a project with a Program class and write the following two methods(headers provided) as described below: 1. A Method, public static int InputValue(int min, int max), to input an integer number that is between (inclusive) the range of a lower bound and an upper bound. The method should accept the lower bound and the upper bound as two parameters and allow users to re-enter the number if the number is not in the range...
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...
Create a class that will store all the information needed for a song. Your class will...
Create a class that will store all the information needed for a song. Your class will store the following data: A string for the song title. A string for the Artist/Band title A string for the Album/Compilation Name A string for the Genre A boolean called liked that represents whether you like the song The class will have the following methods: A constructor that will make a Song object from a song title, artist and album name A constructor that...
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...
ADVERTISEMENT
ADVERTISEMENT
ADVERTISEMENT