In: Computer Science
language is C++
1. Design a class that manages a Pet Food Company's quarterly summarized activity. It should contain the following:
( This is all private data )
Company Name - char[40] // This is a static member
Quarter - char // This is a static member. Validate to be 1-4 in the setter method
Division Name - char[40]
BonusBudgetRate - float - set to 0.02 Total Sales - float
Total Expenses - float 1a. Create a public method named netIncome() which will return total sales - total expenses as float.
2. Create public class methods (Setters and Getters) that load the data values.
3. Do not create getter/setter methods for the BonusBudgetRate item. It can be set in a constructor or initialized to the default value of 0.02. There is no other reference to it.
4. This class needs a header file and a corresponding cpp file.
5. Create a 'driver' program that contains the main() method and includes the header file for PetFoodCompany class.
In the driver program, create an instance of the object PetFoodCompany.
Internally set the Quarter to 1 and the CompanyName to a name of your choosing. Display the CompanyName and Quarter values Prompt for total sales and total expenses for this object Display the result of netIncome(). Below is an example:
Company Name is myCompanyName Current Quarter is 1
Enter Total Sales: 1000
Enter Total Expenses: 600
Net Income = 400
The deliverable is a working program (CPPs & H files) and a UML diagram of the this class.
Note: Could you plz go through this code and let me
know if u need any changes in this.Thank You
=================================
UML Diagram:
==========================================
// PetFoodCompany.h
#ifndef PETFOODCOMPANY_H
#define PETFOODCOMPANY_H
class PetFoodCompany
{
public:
PetFoodCompany();
char getQuarter();
void setQuarter(char quarter);
float getTotalSales();
void setTotalSales(float totalSales);
float getTotalExpences();
void setTotalExpences(float
totalExpences);
double netIncome();
char * getCompanyName();
void setCompanyName(char name[]);
char * getDivisionName();
void setDivisionName(char dname[]);
private:
// Declaring variables
char companyName[40];
static char quarter;
char divisionName[40];
static double BonusBudgetRate;
float totalSales;
float totalExpences;
};
#endif
=========================================
=========================================
#include <iostream>
#include <cstring>
using namespace std;
#include "PetFoodCompany.h"
double PetFoodCompany::BonusBudgetRate = 0.02;
char PetFoodCompany::quarter = '1';
PetFoodCompany::PetFoodCompany()
{
strcpy(companyName, "myCompanyName");
}
char PetFoodCompany::getQuarter()
{
return quarter;
}
void PetFoodCompany::setQuarter(char quarter)
{
if (quarter == '1' || quarter == '2' || quarter == '3' || quarter
== '4')
this->quarter = quarter;
}
float PetFoodCompany::getTotalSales()
{
return totalSales;
}
void PetFoodCompany::setTotalSales(float
totalSales)
{
this->totalSales = totalSales;
}
float PetFoodCompany::getTotalExpences()
{
return totalExpences;
}
void PetFoodCompany::setTotalExpences(float totalExpences)
{
this->totalExpences = totalExpences;
}
char* PetFoodCompany::getCompanyName()
{
return companyName;
}
void PetFoodCompany::setCompanyName(char name[])
{
strcpy(companyName, name);
}
char* PetFoodCompany::getDivisionName()
{
return divisionName;
}
void PetFoodCompany::setDivisionName(char dname[])
{
strcpy(this->divisionName, dname);
}
double PetFoodCompany::netIncome()
{
return (totalSales - totalExpences);
}
=========================================
=========================================
// main.cpp
#include <iostream>
#include <cstring>
using namespace std;
#include "PetFoodCompany.h"
int main()
{
double totalSales,totExpences;
PetFoodCompany pfc;
cout<<"Company Name is
"<<pfc.getCompanyName()<<endl;
cout<<"Current Quarter is
"<<pfc.getQuarter()<<endl;
cout<<"Enter Total Sales: ";
cin>>totalSales;
cout<<"Enter Total Expences: ";
cin>>totExpences;
pfc.setTotalExpences(totExpences);
pfc.setTotalSales(totalSales);
cout<<"Net Income
:"<<pfc.netIncome()<<endl;
return 0;
}
=========================================
======================================
Output:
=====================Could you plz rate me well.Thank You