This is my program and works well. Can you check if I met these parameters: 5 po
ID: 3578848 • Letter: T
Question
This is my program and works well. Can you check if I met these parameters:
5 points main has sufficient comments to explain what is being done.
10 points every function has specifications.
5 points A header file contains the class definition.
5 points A cpp file contains the functions definitions/implementations.
5 points The #ifndef guard is properly used where necessary.
10 points a constructor and destructor are defined and do what they supposed to.
5 points a static variable accumulates the sales for all regions.
5 points All accessor member functions are constant.
5 points an array of objects is declared in main and calls a function to read the data for each of the regions.
20 points Program runs efficiently, correctly and performs the specified task.
10 points Structure of the program (neatness, spacing, indentation, use of variables, organization)
Additional 30 points if at the end, the total of each quarter for the regions is printed by accessing a member function to accumulate the quarters (may require another static variable if you wish).
this are my codes:
#include<iostream>
#include<string>
#include<cstdlib>
#include<iomanip>
using namespace std;
class DivSales
{
public:
string region;
int quarters [4];
double yearlySale;
double allregtot;
DivSales()
{
region = "";
yearlySale = 0;
allregtot = 0;
for(int i=0; i<4; i++)
{
quarters[i]=0;
}
}
~DivSales()
{
}
void getValues()
{
cout<<" Enter Region: ";
cin>>region;
for(int i = 0; i<4;i++)
{
cout<<setw(15)<<" Quarter "<<i+1<< ": ";
cin>> quarters[i];
yearlySale = yearlySale + quarters[i];
}
allregtot = allregtot + yearlySale;
}
string getRegion()
{
return region;
}
double getquatsale(int index)
{
return quarters[index];
}
double getyearlysale()
{
return yearlySale;
}
double gettotsale()
{
return allregtot;
}
};
int main()
{
DivSales obj[4];
int allregquat [4];
int tot=0;
for (int i =0; i<4; i++)
{
obj[i].getValues();
}
cout<<" ----------------------- ";
for(int i=0; i<4; i++)
{
cout<<" "<<obj[i].getRegion();
for(int j=0; j<4; j++)
{
cout<<" Quarter "<<j+1<< ": "<<
obj[i].quarters[j];
}
cout<<""<<endl;
cout<<" Region's total: "<<obj[i].yearlySale;
cout<<" ";
}
for(int i =0; i<4; i++)
{
tot= tot+ obj[i].gettotsale();
}
cout<<""<<endl;
cout<<" All Regions Total: "<< tot;
for(int i=0; i<4; i++)
{
allregquat[i]=0;
}
for(int i=0; i<4; i++)
{
for(int j=0; j<4; j++)
{
allregquat[i]=allregquat[i]+ obj[j].quarters[i];
}
}
cout<<" ";
cout<<" Extra work: ";
for(int i=0; i<4; i++)
{
cout<<" ALL regiongs Quarter" <<i+1<<" : "<<
allregquat[i];
}
cout<<" ";
system("pause");
return 0 ;
}
Explanation / Answer
Only 6,7, 9, 10,11 are being satisfied.
Please add comments and function specifications that will fetch you easy marks. Additional 30 points you should get. Create header file and this one is cpp file. That criteria will also get fulfilled.
Related Questions
drjack9650@gmail.com
Navigate
Integrity-first tutoring: explanations and feedback only — we do not complete graded work. Learn more.