Here is my program. How do i fix the error that is listed at the bottom of the p
ID: 3642559 • Letter: H
Question
Here is my program. How do i fix the error that is listed at the bottom of the page?//////////////////////#include <iostream>
using namespace std;
// Division Sales Class before main
class DivSales
{
// Private data members by default
float quarterSales[4];
float totalSales;
public:
// Public functions
void calculateSales(float q1,float q2,float q3,float q4);
float getSales(int index);
};
void DivSales::calculateSales(float q1,float q2,float q3,float q4)
{
// Puts data in array
totalSales=0;
quarterSales[0]=q1;
quarterSales[1]=q2;
quarterSales[2]=q3;
quarterSales[3]=q4;
// Accumulates all sales
for (int i=0;i<4;i++)
totalSales +=quarterSales[i];
};
// Gets sales for quarter
float DivSales::getSales(int index)
{
return quarterSales[index];
};
//********MAIN************************************
int main ()
{
DivSales divisions[6];
float q1,q2,q3,q4;
// Gets user input for sales
for(int i=0;i<6;i++)
{
cout<<"Enter Sales of Division "<<i+1<<endl;
cout<<"Enter Quarter 1:";
cin>>q1;
cout<<"Enter Quarter 2:";
cin>>q2;
cout<<"Enter Quarter 3:";
cin>>q3;
cout<<"Enter Quarter 4:";
cin>>q4;
divisions[i].calculateSales(q1,q2,q3,q4);
};
// Displays the data. to evenly space the inputs.
cout<<endl<<"QUARTERLY SALES FOR EACH DIVISION"<<endl;
cout<<"Division Quarter1 Quarter2 Quarter3 Quarter4"<<endl;
for(int i=0;i<6;i++)
{
cout<<i+1<<" ";
for(int j=0;j<4;j++)
cout<<" "<<divisions[i].getSales(j)<<" ";
cout<<endl;
};
system("pause");
return 0;
}//////////////////////////////
Error: 1>------ Build started: Project: Ch 4 Project, Configuration: Debug Win32 ------
1> nutty.cpp
1>c:users ickdocumentsisual studio 2010projectsch 4 project solutionch 4 project utty.cpp(12): error C3861: 'clrscr': identifier not found
1>c:users ickdocumentsisual studio 2010projectsch 4 project solutionch 4 project utty.cpp(42): error C3861: 'getch': identifier not found
1>c:users ickdocumentsisual studio 2010projectsch 4 project solutionch 4 project utty.cpp(52): error C3861: 'getch': identifier not found
1>c:users ickdocumentsisual studio 2010projectsch 4 project solutionch 4 project utty.cpp(94): error C3861: 'clrscr': identifier not found
1> Ch 4 Program Challenges.cpp
1> Generating Code...
========== Build: 0 succeeded, 1 failed, 0 up-to-date, 0 skipped ==========
Explanation / Answer
please rate - thanks
there is nothing at all wrong with your code.
those errors say that getch and clrscr were not fond. these ar C instructions not C++, your code does not have either of these instructions.
The problem is the way you compiled it, or something
#include <iostream>
using namespace std;
// Division Sales Class before main
class DivSales
{
// Private data members by default
float quarterSales[4];
float totalSales;
public:
// Public functions
void calculateSales(float q1,float q2,float q3,float q4);
float getSales(int index);
};
void DivSales::calculateSales(float q1,float q2,float q3,float q4)
{
// Puts data in array
totalSales=0;
quarterSales[0]=q1;
quarterSales[1]=q2;
quarterSales[2]=q3;
quarterSales[3]=q4;
// Accumulates all sales
for (int i=0;i<4;i++)
totalSales +=quarterSales[i];
};
// Gets sales for quarter
float DivSales::getSales(int index)
{
return quarterSales[index];
};
//********MAIN************************************
int main ()
{
DivSales divisions[6];
float q1,q2,q3,q4;
// Gets user input for sales
for(int i=0;i<6;i++)
{
cout<<"Enter Sales of Division "<<i+1<<endl;
cout<<"Enter Quarter 1:";
cin>>q1;
cout<<"Enter Quarter 2:";
cin>>q2;
cout<<"Enter Quarter 3:";
cin>>q3;
cout<<"Enter Quarter 4:";
cin>>q4;
divisions[i].calculateSales(q1,q2,q3,q4);
};
// Displays the data. to evenly space the inputs.
cout<<endl<<"QUARTERLY SALES FOR EACH DIVISION"<<endl;
cout<<"Division Quarter1 Quarter2 Quarter3 Quarter4"<<endl;
for(int i=0;i<6;i++)
{
cout<<i+1<<" ";
for(int j=0;j<4;j++)
cout<<" "<<divisions[i].getSales(j)<<" ";
cout<<endl;
};
system("pause");
return 0;
}//////////////////////////////
Related Questions
drjack9650@gmail.com
Navigate
Integrity-first tutoring: explanations and feedback only — we do not complete graded work. Learn more.