I've tried compiling the program below but I keep coming out with these two errors. Errors C2061 and C2082 for lines 32 and 34, respectively. C2061 is a syntax error : identifier 'numerator'. C2082 is redefinition of formal parameter 'dollar'. I followed the example in my book exactly so I don't know what I'm doing wrong or how to interpret the errors. I looked it up in Help but I'm still fuzzy on it. Here's the program:
/*This program will compute the value of a user's holding of one stock.
The user inputs the number of shares of stock and the price per share.
The price is inputted using three arguments: the whole dollar portion,
and the fraction portion which consists of inputting the numerator and
the denominator. The value of the stock is returned.*/
#include <iostream.h>
double stock_price(int dollar, int numerator, int denominator);
//to calculate the number of shares by its price
int main ( )
{
int dollar_portion, numerator_part, denominator_part, number_of_shares;
double result;
cout << "Please input the number of shares." << endl;
cin >> number_of_shares;
cout << "Please input the price of the stock as shown in the following example. ";
cout << "To input the example price of 79 5/8, type in 79, spacemark, 5, spacemark, then 8." << endl;
cin >> dollar_portion >> numerator_part >> denominator_part;
cout << "Press enter to calculate the value of your shares." << endl;
result = stock_price(dollar_portion, numerator_part, denominator_part);
cout << "The value of your stock is " << result;
return 0;
}
double stock_price(int dollar, numerator, denominator)
{
int number_of_shares, dollar, numerator, denominator;
double price;
price = dollar + (numerator/denominator);
return price * number_of_shares;
}
double stock_price(int dollar, int numerator, int denominator)
{
int number_of_shares;
double price;
price = dollar + (numerator/denominator);
return price * number_of_shares;
}