473,499 Members | 1,653 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

functions and parameters

I got two error saying "Error 2 error C2064: term does not evaluate to a
function taking 2 arguments" from the code below. I don't understand why or
what is wrong. Can anyone tell me what I did wrong. I am to C++. Thanks

#include <iostream>

#include <iomanip>

#include <string>

//#include <stdlib>

//#include <math>

using namespace std;

//function phototype

int NumberOfEmployee (void);

int DaysOut(int);

int AverageDaysOut(int, int);

// variable declarations

//int NumberOfEmployee, TotalDaysOut, DaysOut;

//float AverageDaysOut;

void main()

{ int NumberOfEmployee, TotalDaysOut;

int AverageDaysOut;

//cout<<setprecision(2);

//cout.setf(ios::fixed | ios::showpoint);

NumberOfEmployee=NumberOfEmployee();

TotalDaysOut=DaysOut(NumberOfEmployee);

AverageDaysOut=AverageDaysOut(NumberOfEmployee, TotalDaysOut);

cout<<"The number of Employee in your company is "<<NumberOfEmployee<<endl;

cout<<"The total number of days all of your company's employee missed is
"<<TotalDaysOut<<endl;

cout<<"The average days missed for each employee is "<<AverageDaysOut<<endl;

}

int NumberOfEmployee (void)

{

int NumberOfEmployee;
cout<<"How many employees does your company has?: ";

cin>>NumberOfEmployee;

while (NumberOfEmployee < 1)

{

cout<<"Enter the number of employees greater 1: ";

cin>>NumberOfEmployee;

}

return NumberOfEmployee;

}

int DaysOut(int NumberOfEmployee)

{

int TotalDaysOut, DaysOut;

for (int count =1; count <= NumberOfEmployee; count++)

{

cout<<"How many days did employee "<<count<<" missed work during the past
year? : ";

cin>>DaysOut;

while(DaysOut < 0)

{

cout<<"Enter a positive days out: ";

cin>>DaysOut;

}

TotalDaysOut +=DaysOut;

return TotalDaysOut;

}

}

int AverageDaysOut(int NumberOfEmployee, int TotalDaysOut)

{

int AverageDaysOut;

AverageDaysOut = TotalDaysOut/NumberOfEmployee;

return AverageDaysOut;

}
Oct 21 '05 #1
8 1608

"Richard" <no********@yahoo.com> wrote in message
news:3o********************@comcast.com...
I got two error saying "Error 2 error C2064: term does not evaluate to a
function taking 2 arguments" from the code below. I don't understand why
or what is wrong. Can anyone tell me what I did wrong. I am to C++.
Thanks
See below

#include <iostream>

#include <iomanip>

#include <string>

//#include <stdlib>

//#include <math>

using namespace std;

//function phototype

int NumberOfEmployee (void);

int DaysOut(int);

int AverageDaysOut(int, int);

// variable declarations

//int NumberOfEmployee, TotalDaysOut, DaysOut;

//float AverageDaysOut;

void main()

{ int NumberOfEmployee, TotalDaysOut;

int AverageDaysOut;

//cout<<setprecision(2);

//cout.setf(ios::fixed | ios::showpoint);

NumberOfEmployee=NumberOfEmployee();

TotalDaysOut=DaysOut(NumberOfEmployee);

AverageDaysOut=AverageDaysOut(NumberOfEmployee, TotalDaysOut);

cout<<"The number of Employee in your company is
"<<NumberOfEmployee<<endl;

cout<<"The total number of days all of your company's employee missed is
"<<TotalDaysOut<<endl;

cout<<"The average days missed for each employee is
"<<AverageDaysOut<<endl;

}

int NumberOfEmployee (void)

{

int NumberOfEmployee;
cout<<"How many employees does your company has?: ";

cin>>NumberOfEmployee;

while (NumberOfEmployee < 1)

{

cout<<"Enter the number of employees greater 1: ";

cin>>NumberOfEmployee;

}

return NumberOfEmployee;

}

int DaysOut(int NumberOfEmployee)

{

int TotalDaysOut, DaysOut;

for (int count =1; count <= NumberOfEmployee; count++)

{

cout<<"How many days did employee "<<count<<" missed work during the past
year? : ";

cin>>DaysOut;

while(DaysOut < 0)

{

cout<<"Enter a positive days out: ";

cin>>DaysOut;

}

TotalDaysOut +=DaysOut;

return TotalDaysOut;

}

}

int AverageDaysOut(int NumberOfEmployee, int TotalDaysOut)

{

int AverageDaysOut;

AverageDaysOut = TotalDaysOut/NumberOfEmployee;

return AverageDaysOut;

}


You're in serious need of some good books and/or
paying attention in class. :-)

#include <iostream>
#include <ostream>

using namespace std;

int NumberOfEmployee (void);
int DaysOut(int);
double AverageDaysOut(int, int);

int main()
{
int NumOfEmployee(0);
int TotalDaysOut(0);
double AvgDaysOut(0);

NumOfEmployee = NumberOfEmployee();
TotalDaysOut = DaysOut(NumOfEmployee);
AvgDaysOut = AverageDaysOut(NumOfEmployee, TotalDaysOut);

cout << "The number of Employee in your company is "
<< NumOfEmployee << endl;

cout << "The total number of days all of "
"your company's employee missed is "
<< TotalDaysOut << endl;

cout << "The average days missed for each employee is "
<< AvgDaysOut << endl;

return 0;
}

int NumberOfEmployee (void)
{
int NumOfEmployee(0);

cout << "How many employees does your company has?: ";
cin >> NumOfEmployee;

while (NumOfEmployee < 1)
{
cout << "Enter the number of employees greater 1: ";
cin >> NumOfEmployee;
}

return NumOfEmployee;
}

int DaysOut(int NumOfEmployee)
{
int TotalDaysOut(0);
int daysOut(0);

for (int count = 1; count <= NumOfEmployee; count++)
{
cout << "How many days did employee " << count
<< " missed work during the past year? : ";

cin >> daysOut;

while(daysOut < 0)
{
cout << "Enter a positive days out: ";
cin >> daysOut;
}

TotalDaysOut += daysOut;

}

return TotalDaysOut;
}

double AverageDaysOut(int NumOfEmployee, int TotalDaysOut)
{
return static_cast<double>(TotalDaysOut) / NumOfEmployee;
}

-Mike
Oct 21 '05 #2
I got a pretty bad professor and a pretty old book. I got one more
question. I need to create a function which prompt user to enter any
particular month in the year such as January, March or ect. I need to
validate the Month entered. If the user entered Match instead of March, I
need to print out a message telling the user to try again. So far, I can
think of a way to do this. Can you guys me a method and I will try to write
the code. Here is how i do it so far. Thanks.

#include <iostream>

#include <iomanip>

#include <string>

#include <stdlib.h>

using namespace std;

// function phototype

char GetMonth (void);

int main()

{

GetMonth();

}

char GetMonth(void)

{

cout<<"What month do you need to calculate customer usage charge? :";

cin>>Month;

// validation of month go here, but I cannot find a method

return Month[12];
Oct 21 '05 #3
>>>>
int NumOfEmployee(0);
int TotalDaysOut(0);
double AvgDaysOut(0);


Why do you the 0 inside the parenthesis and why is the parenthesis there? I
don't get this point. please help. My book does not do anything like that.
Oct 21 '05 #4
the code was not correct here is the correct one for the month function:

#include <iostream>

#include <iomanip>

#include <string>
using namespace std;

// function phototype
char GetMonth (void);
// variable declaration
char Choice ,Month[12];

char January[12]="January",
February[12]="February",March[12]="March",April[12]="April";

char
May[12]="May",June[12]="June",July[12]="July",August[12]="August",September[12]="September";

char October[12]="October", November[12]="November",December[12]="December";
int main()

{

GetMonth();

}

char GetMonth(void)

{

cout<<"What month do you need to calculate customer usage charge? :";

cin>>Month;

// validation of month go here, but I cannot find a method

return Month[12];
}
Oct 21 '05 #5

Richard wrote:
I got two error saying "Error 2 error C2064: term does not evaluate to a
function taking 2 arguments" from the code below. I don't understand why or
what is wrong. Can anyone tell me what I did wrong. I am to C++. Thanks

#include <iostream>

#include <iomanip>

#include <string>

//#include <stdlib>

//#include <math>

using namespace std;

//function phototype

int NumberOfEmployee (void);

int DaysOut(int);

int AverageDaysOut(int, int);

// variable declarations

//int NumberOfEmployee, TotalDaysOut, DaysOut;

//float AverageDaysOut;

void main()

{ int NumberOfEmployee, TotalDaysOut;

int AverageDaysOut;

//cout<<setprecision(2);

//cout.setf(ios::fixed | ios::showpoint);

NumberOfEmployee=NumberOfEmployee();

TotalDaysOut=DaysOut(NumberOfEmployee);

AverageDaysOut=AverageDaysOut(NumberOfEmployee, TotalDaysOut);

cout<<"The number of Employee in your company is "<<NumberOfEmployee<<endl;

cout<<"The total number of days all of your company's employee missed is
"<<TotalDaysOut<<endl;

cout<<"The average days missed for each employee is "<<AverageDaysOut<<endl;

}

int NumberOfEmployee (void)

{

int NumberOfEmployee;
cout<<"How many employees does your company has?: ";

cin>>NumberOfEmployee;

while (NumberOfEmployee < 1)

{

cout<<"Enter the number of employees greater 1: ";

cin>>NumberOfEmployee;

}

return NumberOfEmployee;

}

int DaysOut(int NumberOfEmployee)

{

int TotalDaysOut, DaysOut;

for (int count =1; count <= NumberOfEmployee; count++)

{

cout<<"How many days did employee "<<count<<" missed work during the past
year? : ";

cin>>DaysOut;

while(DaysOut < 0)

{

cout<<"Enter a positive days out: ";

cin>>DaysOut;

}

TotalDaysOut +=DaysOut;

return TotalDaysOut;

}

}

int AverageDaysOut(int NumberOfEmployee, int TotalDaysOut)

{

int AverageDaysOut;

AverageDaysOut = TotalDaysOut/NumberOfEmployee;

return AverageDaysOut;

}


Your code is so ugly, I dont even feel like looking into it.

Oct 21 '05 #6
Richard wrote:
>>>>

int NumOfEmployee(0);
int TotalDaysOut(0);
double AvgDaysOut(0);

Why do you the 0 inside the parenthesis and why is the parenthesis there? I
don't get this point. please help. My book does not do anything like that.


The code
int i(0);
initializes the integer i with zero, i.e., the constructor of the class
int is called. For integral types like "int" or "double", this syntax
should essentially be equivalent with
int i=0;
The point is that, using the syntax "C c(x);", where C is a class and x
an instance of C, one usually saves one default constructor call. This
is due to the fact that in "C c = x;", the object c is initialized first
with its default constructor, and after that the corresponding
=-operator is called. However, a quantitative benefit will only show up
when more complicated classes C than integral types are used.
Oct 21 '05 #7
Richard wrote:
I got a pretty bad professor
You're kind of stuck with this, unless you drop the course.
and a pretty old book.


This you can fix. I suggest Accelerated C++ by Koenig and Moo.

Brian

--
Please quote enough of the previous message for context. To do so from
Google, click "show options" and use the Reply shown in the expanded
header.
Oct 21 '05 #8
On Fri, 21 Oct 2005 00:17:55 -0500, Richard wrote:
// variable declaration
char Choice ,Month[12];

char January[12]="January",
February[12]="February",March[12]="March",April[12]="April";

char
May[12]="May",June[12]="June",July[12]="July",August[12]="August",
September[12]="September";

char October[12]="October", November[12]="November",December[12]="December";


Having all the month names exactly 12 characters long doesn't really make
sense. But having said that, you probably don't want separate arrays for
each month name anyway. Make Month an array of characters strings; then
you can index into it to get the month name.

const char* Month[] =
{
"January",
"February",
"March",
// Add the rest of the month names here...
};

- Jay

Oct 21 '05 #9

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

7
2250
by: BlueDragon | last post by:
The place where I work is moving to MS SQL Server from Lotus Notes. I have done a lot of coding in Lotus Notes, and have, I suppose, intermediate skills in basic SQL -- queries, insert, updates,...
9
2606
by: Gibby Koldenhof | last post by:
Hiya, Terrible subject but I haven't got a better term at the moment. I've been building up my own library of functionality (all nice conforming ISO C) for over 6 years and decided to adopt a...
2
1881
by: anoop | last post by:
Hello, I created a Public class in .aspx.vb code behind file, now I want to know can I call that functions in the class in the Scripts either client side or server side in .aspx page. also I want...
16
2295
by: Martin Jørgensen | last post by:
Hi, Problem: ======== Some of my output functions are beginning to take pretty many arguments... I mean.... We're talking about 10-15 arguments :-) So I thought to myself, perhaps this is...
13
1705
by: Simon Dean | last post by:
Hi, I have a couple of questions. If you don't mind. Sorry, I do get a bit wordy at times. First one just throws some thoughts around hoping for answers :-) 1) Anyone got a theory on the...
0
7132
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
0
7223
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...
0
7390
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each...
1
4919
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome a new...
0
4602
by: conductexam | last post by:
I have .net C# application in which I am extracting data from word file and save it in database particularly. To store word all data as it is I am converting the whole word file firstly in HTML and...
0
3103
by: TSSRALBI | last post by:
Hello I'm a network technician in training and I need your help. I am currently learning how to create and manage the different types of VPNs and I have a question about LAN-to-LAN VPNs. The...
0
3094
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
1
665
muto222
by: muto222 | last post by:
How can i add a mobile payment intergratation into php mysql website.
0
302
bsmnconsultancy
by: bsmnconsultancy | last post by:
In today's digital era, a well-designed website is crucial for businesses looking to succeed. Whether you're a small business owner or a large corporation in Toronto, having a strong online presence...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.