nationnon
asked on
error
what does this mean?
error C2562: 'main' : 'void' function returning a value: see declaration of 'main'
//these are the lines it pointed to.
char c();
cout.flush();
cout << "Waiting 5 seconds...";
Sleep( 5000 ); // does nothing here
return c();
error C2562: 'main' : 'void' function returning a value: see declaration of 'main'
//these are the lines it pointed to.
char c();
cout.flush();
cout << "Waiting 5 seconds...";
Sleep( 5000 ); // does nothing here
return c();
ASKER CERTIFIED SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
ASKER
it didn't work , can you see anything in this code that would cause an error? It's still giving me the
error C2562: 'main' : 'void' function returning a value
see declaration of 'main'
Oh and could you give me an example of how arrays would be used for the names in this program?
error C2562: 'main' : 'void' function returning a value
see declaration of 'main'
Oh and could you give me an example of how arrays would be used for the names in this program?
ASKER
#include <iostream.h>
#include <windows.h>
double deduction()
{
//variable definitions
const double sTaxPct = .08;
const double fTaxPct = .32;
const double miscPct = .20;
return (sTaxPct + fTaxPct + miscPct);
}//end calculation function
void main()
// Declare and define variables
{
char fEfirstName[10];
char fElastName[10];
char sEfirstName[10];
char sElastName[10];
double fEgPay;
double fEnPay;
double sEgPay;
double sEnPay;
double fErate;
double fEhrs;
double sErate;
double sEhrs;
char c();
cout.flush();
cout << "Waiting 5 seconds...";
Sleep( 5000 ); // does nothing here
return
//end of sleep function
//User entered information
cout <<"Enter first employee's last name: ";
cin >> fElastName;
cout <<"Enter first employee's first name: ";
cin >> fEfirstName;
cout <<"Enter first employee's pay rate: ";
cin >> fErate;
cout <<"Enter first employee's hours: ";
cin >> fEhrs;
cout << "Enter second employee's last name: ";
cin >> sElastName;
cout << "Enter second employee's first name: ";
cin >> sEfirstName;
cout << "Enter second employee's hours: ";
cin >> sEhrs;
cout << "Enter second employee's rate: ";
cin >> sErate;
// employee hours * rate & netpay deduction
fEgPay = fErate * fEhrs;
sEgPay = fErate * sEhrs;
fEnPay = sEgPay * deduction();
sEnPay = sEgPay * deduction();
// ask user which employee they want to view
int nEmployee;
cout << "Choose Employee 1 or 2: ";
cin >> nEmployee;
if (nEmployee<=1)
cout << fEfirstName << " " << fElastName << "'s gross pay was " << fEgPay << " "<< "but after deductions the pay is now " << fEnPay << endl;
cout << c() << endl;
if (nEmployee>=2)
cout << sEfirstName << " " << sElastName << "'s gross pay was " << sEgPay << " " << "but after deductions the pay is now " << sEnPay << endl;
cout << c() << endl;
while (nEmployee==1 || nEmployee==2);
}
#include <windows.h>
double deduction()
{
//variable definitions
const double sTaxPct = .08;
const double fTaxPct = .32;
const double miscPct = .20;
return (sTaxPct + fTaxPct + miscPct);
}//end calculation function
void main()
// Declare and define variables
{
char fEfirstName[10];
char fElastName[10];
char sEfirstName[10];
char sElastName[10];
double fEgPay;
double fEnPay;
double sEgPay;
double sEnPay;
double fErate;
double fEhrs;
double sErate;
double sEhrs;
char c();
cout.flush();
cout << "Waiting 5 seconds...";
Sleep( 5000 ); // does nothing here
return
//end of sleep function
//User entered information
cout <<"Enter first employee's last name: ";
cin >> fElastName;
cout <<"Enter first employee's first name: ";
cin >> fEfirstName;
cout <<"Enter first employee's pay rate: ";
cin >> fErate;
cout <<"Enter first employee's hours: ";
cin >> fEhrs;
cout << "Enter second employee's last name: ";
cin >> sElastName;
cout << "Enter second employee's first name: ";
cin >> sEfirstName;
cout << "Enter second employee's hours: ";
cin >> sEhrs;
cout << "Enter second employee's rate: ";
cin >> sErate;
// employee hours * rate & netpay deduction
fEgPay = fErate * fEhrs;
sEgPay = fErate * sEhrs;
fEnPay = sEgPay * deduction();
sEnPay = sEgPay * deduction();
// ask user which employee they want to view
int nEmployee;
cout << "Choose Employee 1 or 2: ";
cin >> nEmployee;
if (nEmployee<=1)
cout << fEfirstName << " " << fElastName << "'s gross pay was " << fEgPay << " "<< "but after deductions the pay is now " << fEnPay << endl;
cout << c() << endl;
if (nEmployee>=2)
cout << sEfirstName << " " << sElastName << "'s gross pay was " << sEgPay << " " << "but after deductions the pay is now " << sEnPay << endl;
cout << c() << endl;
while (nEmployee==1 || nEmployee==2);
}
ASKER
Adjusted points from 50 to 80
I have done some little changes, i not sure what you were tring to do on the last line of the code - so i had a guess
#include <iostream.h>
#include <windows.h>
double deduction()
{
//variable definitions
const double sTaxPct = .08;
const double fTaxPct = .32;
const double miscPct = .20;
return (sTaxPct + fTaxPct + miscPct);
}//end calculation function
void main()
// Declare and define variables
{
char fEfirstName[10];
char fElastName[10];
char sEfirstName[10];
char sElastName[10];
double fEgPay;
double fEnPay;
double sEgPay;
double sEnPay;
double fErate;
double fEhrs;
double sErate;
double sEhrs;
int nEmployee;
//char c();
cout.flush();
cout << "Waiting 5 seconds...";
Sleep( 5000 ); // does nothing here
// return
//end of sleep function
//User entered information
cout <<"Enter first employee's last name: ";
cin >> fElastName;
cout <<"Enter first employee's first name: ";
cin >> fEfirstName;
cout <<"Enter first employee's pay rate: ";
cin >> fErate;
cout <<"Enter first employee's hours: ";
cin >> fEhrs;
cout << "Enter second employee's last name: ";
cin >> sElastName;
cout << "Enter second employee's first name: ";
cin >> sEfirstName;
cout << "Enter second employee's hours: ";
cin >> sEhrs;
cout << "Enter second employee's rate: ";
cin >> sErate;
// employee hours * rate & netpay deduction
fEgPay = fErate * fEhrs;
sEgPay = fErate * sEhrs;
fEnPay = sEgPay * deduction();
sEnPay = sEgPay * deduction();
// ask user which employee they want to view
cout << "Choose Employee 1 or 2: ";
cin >> nEmployee;
if (nEmployee<=1)
cout << fEfirstName << " " << fElastName << "'s gross pay was " << fEgPay << " "<< "but after deductions the pay is now " << fEnPay << endl;
cout << endl;
if (nEmployee>=2)
cout << sEfirstName << " " << sElastName << "'s gross pay was " << sEgPay << " " << "but after deductions the pay is now " << sEnPay << endl;
cout << endl;
getchar(); //wait for keypress so we can see output
return;
//while (nEmployee==1 || nEmployee==2);
}
#include <iostream.h>
#include <windows.h>
double deduction()
{
//variable definitions
const double sTaxPct = .08;
const double fTaxPct = .32;
const double miscPct = .20;
return (sTaxPct + fTaxPct + miscPct);
}//end calculation function
void main()
// Declare and define variables
{
char fEfirstName[10];
char fElastName[10];
char sEfirstName[10];
char sElastName[10];
double fEgPay;
double fEnPay;
double sEgPay;
double sEnPay;
double fErate;
double fEhrs;
double sErate;
double sEhrs;
int nEmployee;
//char c();
cout.flush();
cout << "Waiting 5 seconds...";
Sleep( 5000 ); // does nothing here
// return
//end of sleep function
//User entered information
cout <<"Enter first employee's last name: ";
cin >> fElastName;
cout <<"Enter first employee's first name: ";
cin >> fEfirstName;
cout <<"Enter first employee's pay rate: ";
cin >> fErate;
cout <<"Enter first employee's hours: ";
cin >> fEhrs;
cout << "Enter second employee's last name: ";
cin >> sElastName;
cout << "Enter second employee's first name: ";
cin >> sEfirstName;
cout << "Enter second employee's hours: ";
cin >> sEhrs;
cout << "Enter second employee's rate: ";
cin >> sErate;
// employee hours * rate & netpay deduction
fEgPay = fErate * fEhrs;
sEgPay = fErate * sEhrs;
fEnPay = sEgPay * deduction();
sEnPay = sEgPay * deduction();
// ask user which employee they want to view
cout << "Choose Employee 1 or 2: ";
cin >> nEmployee;
if (nEmployee<=1)
cout << fEfirstName << " " << fElastName << "'s gross pay was " << fEgPay << " "<< "but after deductions the pay is now " << fEnPay << endl;
cout << endl;
if (nEmployee>=2)
cout << sEfirstName << " " << sElastName << "'s gross pay was " << sEgPay << " " << "but after deductions the pay is now " << sEnPay << endl;
cout << endl;
getchar(); //wait for keypress so we can see output
return;
//while (nEmployee==1 || nEmployee==2);
}
Ok i have added an example of how to use array. Note this is not particularly good, but it works.
#include <iostream.h>
#include <windows.h>
double deduction()
{
//variable definitions
const double sTaxPct = .08;
const double fTaxPct = .32;
const double miscPct = .20;
return (sTaxPct + fTaxPct + miscPct);
}//end calculation function
void main()
// Declare and define variables
{
char EfirstName[50] [10];
char ElastName[50] [10];
//char sEfirstName[10];
//char sElastName[10];
double EgPay[50];
double EnPay[50];
//double sEgPay;
//double sEnPay;
double Erate[50];
double Ehrs[50];
//double sErate;
//double sEhrs;
int nEmployee;
//char c();
cout.flush();
cout << "Waiting 5 seconds...";
Sleep( 5000 ); // does nothing here
// return
//end of sleep function
//User entered information
cout <<"Enter first employee's last name: ";
cin >> ElastName[0];
cout <<"Enter first employee's first name: ";
cin >> EfirstName[0];
cout <<"Enter first employee's pay rate: ";
cin >> Erate[0];
cout <<"Enter first employee's hours: ";
cin >> Ehrs[0];
cout << "Enter second employee's last name: ";
cin >> ElastName[1];
cout << "Enter second employee's first name: ";
cin >> EfirstName[1];
cout << "Enter second employee's hours: ";
cin >> Ehrs[1];
cout << "Enter second employee's rate: ";
cin >> Erate[1];
// employee hours * rate & netpay deduction
EgPay[0] = Erate[0] * Ehrs[0];
EgPay[1] = Erate[1] * Ehrs[1];
//sEgPay[0] = fErate * sEhrs;
EnPay[0] = EgPay[0] * deduction();
EnPay[1] = EgPay[1] * deduction();
//sEnPay = sEgPay * deduction();
// ask user which employee they want to view
cout << "Choose Employee 1 or 2: ";
cin >> nEmployee;
if (nEmployee<=1)
cout << EfirstName[0] << " " << ElastName[0] << "'s gross pay was " << EgPay[0] << " "<< "but after deductions the pay is now " << EnPay[0] << endl;
cout << endl;
if (nEmployee>=2)
cout << EfirstName[1] << " " << ElastName[1] << "'s gross pay was " << EgPay[1] << " " << "but after deductions the pay is now " << EnPay[1] << endl;
cout << endl;
getchar(); //wait for keypress so we can see output
return;
//while (nEmployee==1 || nEmployee==2);
}
I declared an array of 50 elements,but have only used the 1st 2 elements (like you previously had) you will need to employ some looping mechanism, to loop through these when printing out the text.
I hope this helps
#include <iostream.h>
#include <windows.h>
double deduction()
{
//variable definitions
const double sTaxPct = .08;
const double fTaxPct = .32;
const double miscPct = .20;
return (sTaxPct + fTaxPct + miscPct);
}//end calculation function
void main()
// Declare and define variables
{
char EfirstName[50] [10];
char ElastName[50] [10];
//char sEfirstName[10];
//char sElastName[10];
double EgPay[50];
double EnPay[50];
//double sEgPay;
//double sEnPay;
double Erate[50];
double Ehrs[50];
//double sErate;
//double sEhrs;
int nEmployee;
//char c();
cout.flush();
cout << "Waiting 5 seconds...";
Sleep( 5000 ); // does nothing here
// return
//end of sleep function
//User entered information
cout <<"Enter first employee's last name: ";
cin >> ElastName[0];
cout <<"Enter first employee's first name: ";
cin >> EfirstName[0];
cout <<"Enter first employee's pay rate: ";
cin >> Erate[0];
cout <<"Enter first employee's hours: ";
cin >> Ehrs[0];
cout << "Enter second employee's last name: ";
cin >> ElastName[1];
cout << "Enter second employee's first name: ";
cin >> EfirstName[1];
cout << "Enter second employee's hours: ";
cin >> Ehrs[1];
cout << "Enter second employee's rate: ";
cin >> Erate[1];
// employee hours * rate & netpay deduction
EgPay[0] = Erate[0] * Ehrs[0];
EgPay[1] = Erate[1] * Ehrs[1];
//sEgPay[0] = fErate * sEhrs;
EnPay[0] = EgPay[0] * deduction();
EnPay[1] = EgPay[1] * deduction();
//sEnPay = sEgPay * deduction();
// ask user which employee they want to view
cout << "Choose Employee 1 or 2: ";
cin >> nEmployee;
if (nEmployee<=1)
cout << EfirstName[0] << " " << ElastName[0] << "'s gross pay was " << EgPay[0] << " "<< "but after deductions the pay is now " << EnPay[0] << endl;
cout << endl;
if (nEmployee>=2)
cout << EfirstName[1] << " " << ElastName[1] << "'s gross pay was " << EgPay[1] << " " << "but after deductions the pay is now " << EnPay[1] << endl;
cout << endl;
getchar(); //wait for keypress so we can see output
return;
//while (nEmployee==1 || nEmployee==2);
}
I declared an array of 50 elements,but have only used the 1st 2 elements (like you previously had) you will need to employ some looping mechanism, to loop through these when printing out the text.
I hope this helps
ASKER
It's saying getchar() is an undeclared identifier, how would I fix that?
You could try getch()
ASKER
That was some sort of type-o, i'm sorry it is getch().
ASKER