Hey everyone, this is a big one.
The question has asked that I define functions and then write the function main to test the functions I wrote. I keep getting the following error at my first cout in main:
error C2679: binary '<<' : no operator found which takes a right-hand operand of type 'void' (or there is no acceptable conversion)
I'm not sure what this is saying.
In addition, I need help with defining two of my functions and writing code to test them. They are as follows:
Write the definition of the function nextChar that sets the value of z to the next character stored in z.
Write the definition of the function funcOne that prompts the user to input a number. The function then changes the value of x to 2 times the old value of x plus the value of y minus the value entered by the user.
Now, with #2 I'm pretty sure I have the function defined right, though I don't know how to test it. #1 though, I have no clue how to define that function, though I did attempt it =/.
Could someone look through my code, and let me know if they notice any huge mistakes? This is our second chapter on user-defined functions, so I'm still learning about call by reference and whatnot. I have commented my code minimaly to assist you in finding the parts I'm having a tough time with.
Thanks guys! :mrgreen:
code:
#include <iostream>
#include <iomanip>
using namespace std ;
void initialize ( int& , int& , char& ) ;
void getHoursRate ( double& , double& ) ;
double payCheck ( double& , double& ) ;
void printCheck ( double , double, double ) ;
int main()
{
int x ;
int y ;
int w ;
char z ;
double rate ;
double hours ;
double amount ;
cout << initialize( x , y , z ) << endl ; //error is here
cout << getHoursRate() << endl ;
cout << payCheck( hours , rate ) << endl ;
printCheck( hours, rate, amount ) << endl ;
cout << funcOne( w, x, y ) ; //confusion starts here
cout <<
}
void initialize ( int& x, int& y, char& z )
{
x = y = 0 ;
z = ' ' ;
}
void getHoursRate ( double& hours , double& rate )
{
cout << "Hours worked: " << endl ;
cin >> hours ;
cout << "Rate: " << endl ;
cin >> rate ;
}
double payCheck ( double& hours, double& rate )
{
double pay ;
int ot ;
if ( (hours - 40 <= 0 ) )
pay = rate * hours ;
else
{
ot = hours - 40 ;
pay = (40 * rate) + (ot * rate * 1.5) ;
}
return pay ;
}
void printCheck ( double hours , double rate , double pay )
{
cout << setprecision(2) << fixed << showpoint << setfill('.') << left ;
cout << "Hours" << setw(15) << "Rate" << setw(15) << "Amount Due" << endl << endl ;
cout << hours << setw(15) << "$" << rate << setw(15) << "$" << pay << endl ;
}
void funcOne ( double in, int x, int y ) //number 2 in my post
{
cout << "Input a value: " << endl ;
cin >> in ;
x = x * x + ( y - in ) ;
}
char nextChar ( char ch ) //number 1 in my post
{
ch = ch++ ;
}