I need help fixing the following C++ program! I keep recieving the same error ev
ID: 3696515 • Letter: I
Question
I need help fixing the following C++ program! I keep recieving the same error everytime and I have no idea how to fix it. The Error I recieve is:
In function 'int main()':
37:16: error: 'getdata' was not declared in this scope
49:28: error: 'comparedata' was not declared in this scope
PLEASE HELP!!!! Please explain what you did to fix the code, Thank You so Much!!
#include
using namespace std;
class MonthlyBudget
{
public:
double Housing,
Utilities,
HouseholdExpenses,
Transportation,
Food,
Medical,
Insurance,
Entertainment,
Clothing,
Miscellaneous;
void comparedata(MonthlyBudget,MonthlyBudget,MonthlyBudget);
MonthlyBudget getdata();
};
int main()
{
MonthlyBudget Set;
Set.Housing=500;
Set.Utilities=150;
Set.HouseholdExpenses=65;
Set.Transportation=50;
Set.Food=250;
Set.Medical=30;
Set.Insurance=100;
Set.Entertainment=150;
Set.Clothing=75;
Set.Miscellaneous=50;
MonthlyBudget Spent;
Spent=getdata();
MonthlyBudget Left;
Left.Housing=Set.Housing-Spent.Housing;
Left.Utilities=Set.Utilities-Spent.Utilities;
Left.HouseholdExpenses=Set.HouseholdExpenses-Spent.HouseholdExpenses;
Left.Transportation=Set.Transportation-Spent.Transportation;
Left.Food=Set.Food-Spent.Food;
Left.Medical=Set.Medical-Spent.Medical;
Left.Insurance=Set.Insurance-Spent.Insurance;
Left.Entertainment=Set.Entertainment-Spent.Entertainment;
Left.Clothing=Set.Clothing-Spent.Clothing;
Left.Miscellaneous=Set.Miscellaneous-Spent.Miscellaneous;
comparedata(Set,Spent,Left);
cout<<"========================================================================="<<endl;
return 0;
}
// Function name: getdata
// Purpose: collects the amounts spent by the user
// Return value: returns Temp which is pasted onto Spent in the main function
MonthlyBudget getdata()
{
MonthlyBudget Temp;
cout<<"========================================================================="< cout<<"Please Enter The Amounts You Spent on Each Budget Item in The Past Month!"< cout<<"How Much Did You Spend on Housing: ";
cin>>Temp.Housing;
cout<<"How Much Did You Spend on Utilities: ";
cin>>Temp.Utilities;
cout<<"How Much Did You Spend on Household Expenses: ";
cin>>Temp.HouseholdExpenses;
cout<<"How Much Did You Spend on Transportation: ";
cin>>Temp.Transportation;
cout<<"How Much Did You Spend on Food: ";
cin>>Temp.Food;
cout<<"How Much Did You Spend on Medical: ";
cin>>Temp.Medical;
cout<<"How Much Did You Spend on Insurance: ";
cin>>Temp.Insurance;
cout<<"How Much Did You Spend on Entertainment: ";
cin>>Temp.Entertainment;
cout<<"How Much Did You Spend on Clothing: ";
cin>>Temp.Clothing;
cout<<"How Much Did You Spend on Miscellaneous: ";
cin>>Temp.Miscellaneous;
cout<<"========================================================================="< return Temp;
}
// Function name: comparedata
// Purpose: To compare the budget with the amount spent
// Parameters: MonthlyBudget
void comparedata(MonthlyBudget Set,MonthlyBudget Spent,MonthlyBudget Left)
{
int Budget=1420;
int BudgetLeft;
double Total;
if(Set.Housing>Spent.Housing)
cout<<"You are "<
Explanation / Answer
The program compiles without any error.Check your logics and results.
#include<iostream>
using namespace std;
class MonthlyBudget
{
public:
double Housing,
Utilities,
HouseholdExpenses,
Transportation,
Food,
Medical,
Insurance,
Entertainment,
Clothing,
Miscellaneous;
void comparedata(MonthlyBudget,MonthlyBudget,MonthlyBudget);
MonthlyBudget getdata();
};
MonthlyBudget::MonthlyBudget getdata()
{
MonthlyBudget Temp;
cout<<"=========================================================================";
cout<<"Please Enter The Amounts You Spent on Each Budget Item in The Past Month!";
cout<<"How Much Did You Spend on Housing: ";
cin>>Temp.Housing;
cout<<"How Much Did You Spend on Utilities: ";
cin>>Temp.Utilities;
cout<<"How Much Did You Spend on Household Expenses: ";
cin>>Temp.HouseholdExpenses;
cout<<"How Much Did You Spend on Transportation: ";
cin>>Temp.Transportation;
cout<<"How Much Did You Spend on Food: ";
cin>>Temp.Food;
cout<<"How Much Did You Spend on Medical: ";
cin>>Temp.Medical;
cout<<"How Much Did You Spend on Insurance: ";
cin>>Temp.Insurance;
cout<<"How Much Did You Spend on Entertainment: ";
cin>>Temp.Entertainment;
cout<<"How Much Did You Spend on Clothing: ";
cin>>Temp.Clothing;
cout<<"How Much Did You Spend on Miscellaneous: ";
cin>>Temp.Miscellaneous;
cout<<"=========================================================================";
}
// Function name: comparedata
// Purpose: To compare the budget with the amount spent
// Parameters: MonthlyBudget
void MonthlyBudget::comparedata(MonthlyBudget Set,MonthlyBudget Spent,MonthlyBudget Left)
{
int Budget=1420;
int BudgetLeft;
double Total;
if(Set.Housing>Spent.Housing)
cout<<"You are ";}
int main()
{
MonthlyBudget Set;
Set.Housing=500;
Set.Utilities=150;
Set.HouseholdExpenses=65;
Set.Transportation=50;
Set.Food=250;
Set.Medical=30;
Set.Insurance=100;
Set.Entertainment=150;
Set.Clothing=75;
Set.Miscellaneous=50;
MonthlyBudget Spent;
Spent=getdata();
MonthlyBudget Left;
Left.Housing=Set.Housing-Spent.Housing;
Left.Utilities=Set.Utilities-Spent.Utilities;
Left.HouseholdExpenses=Set.HouseholdExpenses-Spent.HouseholdExpenses;
Left.Transportation=Set.Transportation-Spent.Transportation;
Left.Food=Set.Food-Spent.Food;
Left.Medical=Set.Medical-Spent.Medical;
Left.Insurance=Set.Insurance-Spent.Insurance;
Left.Entertainment=Set.Entertainment-Spent.Entertainment;
Left.Clothing=Set.Clothing-Spent.Clothing;
Left.Miscellaneous=Set.Miscellaneous-Spent.Miscellaneous;
Set.comparedata(Set,Spent,Left);
cout<<"========================================================================="<<endl;
getch();
return 0;
}
Related Questions
drjack9650@gmail.com
Navigate
Integrity-first tutoring: explanations and feedback only — we do not complete graded work. Learn more.