Hey guys i am making a small finance calculator for practice , im attempting the use of functions but from my reading it looks like im doing it correctly but its not compiling any ideas ?
#include <cstdlib>
#include <iostream>
#include <string>
usingnamespace std;
char cont2[50];
int multiplication(int a)
{int r;
r=a*12;
return(r);
}
int main()
{
cout<<" Welcome to the Finance wizard "<<"\n";
cout<<" This was created by : Seth Prado"<<"\n";
cout<<"\n\n"<<" This program was made as a learning experience"<<"\n";
cout<<" Please enter all amounts to the nearest dollar value"<<"\n";
int cont;
cout<<"\n\n"<<" MAIN MENU "<<"\n\n"<<"Press '1' to continue";
cout<<"\n"<<"Press '2' to exit"<<"\n";
cin>>cont;
if (cont==1)
{
goto program;
}
if (cont==2)
{
system("PAUSE");
return EXIT_SUCCESS;
}
/* this is the initial program , if anyone knows of a better way to get
here instead of "" GOTO "" please let me know */
program:
system("CLS");
/* this is going to be the int bank */
int Totalincome;//Monthly
int Electric;//electir bill
int Gas;
int Water;
int tuition;
int CarGas;
int Cinsurance;
int Hinsurance;
int Rent;
int CC1;
int CC2;
int CC3;
int CC4;
int CC5;
int cphone;
int Hphone;
int Cable;
int web;
int GroceryCost;
int Emed;
int Dental;
int Hospital;
int Savings;
int Leisure;
int SecondaryIncome;
int incomeleftm;
int Billtotalm;
int totsav;
int incomelefty;
int BillYear;
int miscspend;
cout<<"All fields are based monthly \n";
cout<<"Please enter Amounts to the nearest Dollar";
cout<<"\nIf field does not apply enter '0' \n";
cout<<"Please enter your income amount \n";
cin>>Totalincome;
cout<<"Electric Bill Amount : \n";
cin>>Electric;
cout<<"Gas Bill Amount: \n";
cin>>Gas;
cout<<"Water Bill amount: \n";
cin>>Water;
cout<<"Tuition Payment or studen loan: \n";
cin>>tuition;
cout<<" Enter amount for vehicle fuel (monthly : \n";
cin>>CarGas;
cout<<"Car insurance payment : \n";
cin>>Cinsurance;
cout<<"Home Insurance payment : \n";
cin>>Hinsurance;
cout<<"Home Payment / Rent : \n";
cin>>Rent;
cout<<"Credit card payment no.1 : \n";
cin>>CC1;
cout<<"Credit card payment no.2 : \n";
cin>>CC2;
cout<<"Credit card payment no.3 : \n";
cin>>CC3;
cout<<"Credit card payment no.4 : \n";
cin>>CC4;
cout<<"Credit card payment no.5 : \n";
cin>>CC5;
cout<<"Cell Phone payment : \n";
cin>>cphone;
cout<<"House Phone payment : \n";
cin>>Hphone;
cout<<"Cable tv payment : \n";
cin>>Cable;
cout<<"Internet Bill : \n";
cin>>web;
cout<<"Estimated grocery / misc supply cost : \n";
cin>>GroceryCost;
cout<<"Medical Bill for vision: \n";
cin>>Emed;
cout<<"Medical Bill for dental: \n";
cin>>Dental;
cout<<"Medical Bill for hospitals+misc med: \n";
cin>>Hospital;
cout<<"Amount wanting to save monthly : \n";
cin>>Savings;
cout<<" Fun money / Leisure spending allowed for month: \n";
cin>>Leisure;
cout<<" Amount of money having pitched in *roomates* : \n";
cin>>SecondaryIncome;
cout<<" Amount of any other bills / deductions \n";
cout<<" that does not apply in above fields: \n";
cin>>miscspend;
cout<<"Would you like to see your estimated finances? ";
cout<<"\n Type ' Yes ' or ' No ' \n ";
cin>>cont2;
if (!strcmp("Yes", cont2)){;
system ("CLS");}
cout<<" \n\n\n\n Your Monthly Finances in totals : \n";
/* ALL Expenses are entered ^^^ all below will be formulas for
totals */
Billtotalm=(Electric+Gas+Water+tuition+CarGas+Cinsurance+
Hinsurance+Rent+(CC1)+(CC2)+(CC3)+(CC4)+(CC5)+(cphone)+Hphone+Cable+
web+GroceryCost+Emed+Dental+Hospital+Savings+Leisure+miscspend);
incomeleftm=(Totalincome+SecondaryIncome)-Billtotalm;
// Monthly Bill total and leftover income
cout<<" Your total amount spent on bills for the month is: \n";
cout<<Billtotalm;
cout<<" The total amount of money you have left over monthly";
cout<<" is : \n"<<incomeleftm;
cout<<"\n\n\n\n";
cout<<" Would you like to see your *estimated* Yearly expenses?";
cout<<"\n"<<" Type ' Yes or No' \n";
cin>>cont2;
if (!strcmp("Yes", cont2));
system ("CLS");}
//this area below is where i think i am having the trouble
int CalculateEstimatedYearlySaving(int Savings)
{
return Savings * 12;
}
cout<<CalculateEstimatedYearlySaving;
int CalculateEstimatedBillYearly(int Billtotalm)
{
return Billtotalm * 12;
}
cout<<CalculateEstimatedBillYearly;
int CalculateEstimatedLeftYearly(int incomeleftm)
{
return incomeleftm * 12;
}
cout<<CalculateEstimatedLeftYearly;
system("PAUSE");
return EXIT_SUCCESS;
You're not using functions correctly. You should define them outside of 'main()' and you can either save the data returned from them to a variable or you can pipe it right to cout but what you're trying to do on lines 160, 166 and 172 is confused.