I get the error "Error:" "not declared in this area" for declaring int getValue function at compile time.
This function should take integers entered by the user and deliver them to the main function.
Did I declare functions correctly?
#include <iostream>
#include <string>
using namespace std;
int getValue(message);
char getLetter(message);
int main()
{
int thisYear, thisMonth, year, month, ageYear, ageMonth;
char again = 'y';
string message;
cout << "This program asks you to enter today year in 4 digits,\n"
<< "and today month number.\n\n"
<< "Then you will be asked to enter your birth in 4 digits,\n"
<< "and your birth month in 2 digits.\n\n"
<< "The program will calculate and display your age in years and months.\n";
message="Enter today year in 4 digits";
getValue(message)==thisYear;
message="Enter today month in 2 digits";
getValue(message)==thisMonth;
do
{
message="Enter your birth year in 4 digits";
getValue(message)==year;
message="Enter your birth month in 2 digits";
getValue(message)==month;
ageYear = thisYear - year;
ageMonth = thisMonth - month;
if (thisMonth < month)
{
ageYear--;
ageMonth += 12;
}
cout << "\nYou are " << ageYear << " years and " << ageMonth << " months old.\n";
message="Do you want to calculate another age? (y/n)";
getLetter(message)==again;
again = tolower(again);
}while (again == 'y');
return 0;
}
int getValue(message)
{
int value;
cout << message;
cin >> value;
return value;
}
char getLetter(message)
{
char letter;
cout << " Do you wish to enter another date? (y/n)";
cin >> letter;
return letter;
}
source
share