Need help with display
Jan 30, 2016 at 8:53pm UTC
Hi i am having trouble figuring out why it doesn't show my display when I run my program can somebody point me in the right direction of what I'm doing wrong?
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92
#include <iostream>
#include<iomanip>
using namespace std;
float getMonthlyIncome()
{
float income;
cout << "\tYour monthly income: " ;
cin >> income;
return income;
}
float getBudgetedLiving()
{
float budgetedliving;
cout << "\tYour budgeted living expenses: " ;
cin >> budgetedliving;
return budgetedliving;
}
float getActualLiving()
{
float actualLiving;
cout << "\tYour actual living expenses: " ;
cin >> actualLiving;
return actualLiving;
float getActualTaxes()
{
float actualTaxes;
cout << "\tYour actual taxes withheld: " ;
cin >> actualTaxes;
return actualTaxes;
}
float getActualTithe()
{
float actualTithe;
cout << "\tYour tithe offerings: " ;
cin >> actualTithe;
return actualTithe;
}
float getOther()
{ float other;
cout << "\tYour actual other expenses: " ;
cin >> other;
return other;
}
void display(float income, float budgetedLiving, float actualLiving, float actualTaxes, float actualTithe, float other)
{
cout << "\n" << "The following is a report on your monthly"
<< " expenses\n" ;
cout.setf(ios::fixed); // no scientific notation please
cout.setf(ios::showpoint); // always show the decimal for real numbers
cout.precision(2); // two digits after the decimal
cout << "\tItem Budget Actual\n" ;
cout << "\t=============== =============== ===============\n" ;
cout << "\tIncome $" << setw(11) << income << " $" << setw(11) << income <<"\n" ;
cout << "\tTaxes $" << setw(11) << 0.00 << " $" << setw(11) << actualTaxes <<"\n" ; //displays budget table using variables
cout << "\tTithing $" << setw(11) << 0.00 << " $" << setw(11) << actualTithe <<"\n" ;
cout << "\tLiving $" << setw(11) << budgetedLiving << " $" << setw(11) << actualLiving << "\n" ;
cout << "\tOther $" << setw(11) << 0.00 << " $" << setw(11) << other << "\n" ;
cout << "\t=============== =============== ===============\n" ;
cout << "\tDifference $" << setw(11) << 0.00 << " $" << setw(11) << 0.00 << "\n" ;
}
int main()
{
cout << "This program keeps track of your monthly budget\n" //Greeting
<< "Please enter the following:\n" ;
float income = 0;
income = getMonthlyIncome(); // variable for income function
float budgetedLiving = 0;
budgetedLiving = getBudgetedLiving(); // variable for budgeted living function
float actualLiving = 0;
actualLiving = getActualLiving(); // variable for actual living function
float actualTaxes = 0;
actualTaxes = getActualTaxes(); // variable for actual taxes function
float actualTithe = 0;
actualTithe = getActualTithe(); // variable for actual tithe function
float other = 0;
other = getOther(); // variable for other function
void display(float income, float budgetedLiving, float actualLiving, float actualTaxes, float actualTithe, float other);
return 0;
}
Last edited on Jan 30, 2016 at 9:08pm UTC
Jan 30, 2016 at 8:54pm UTC
Jan 30, 2016 at 9:09pm UTC
thanks for the link
Jan 30, 2016 at 9:15pm UTC
In the function float getActualLiving() the closing curly brace is missing.
Instead of calling the funcion display you declare it in main.
1 2
void display(float income, float budgetedLiving, float actualLiving,
float actualTaxes, float actualTithe, float other);
If you add the missing brace and call display with the correct form it will work.
display(income, budgetedLiving, actualLiving, actualTaxes,actualTithe, other);
Output:
This program keeps track of your monthly budget
Please enter the following:
Your monthly income: 1000
Your budgeted living expenses: 800
Your actual living expenses: 700
Your actual taxes withheld: 100
Your tithe offerings: 55
Your actual other expenses: 44
The following is a report on your monthly expenses
Item Budget Actual
=============== =============== ===============
Income $ 1000.00 $ 1000.00
Taxes $ 0.00 $ 100.00
Tithing $ 0.00 $ 55.00
Living $ 800.00 $ 700.00
Other $ 0.00 $ 44.00
=============== =============== ===============
Difference $ 0.00 $ 0.00
Press any key to continue . . .
Topic archived. No new replies allowed.