In shopping for a new house, you must consider several factors. In this problem
ID: 3623305 • Letter: I
Question
In shopping for a new house, you must consider several factors. In this problem the initial cost of the house, estimated annual fuel costs, and annual tax rate are available. Write a program that will determine the total cost after a five-year period for each house data below. You should be able to inspect your program output to determine the "best buy".
Initial House Cost Annual Fuel Cost Tax Rate
$175,000 $2500 .025
$200,000 $2800 .025
$210,000 $2050 .020
To calculate the house cost, add the fuel cost for five years to the initial cost, then add the taxes for five years. Taxes for one year are computed by multiplying the tax rate by the initial cost. Write and call a function that displays instructions to the program user and another function that computes and returns the house cost given the initial cost, the annual fuel cost, and the tax rate.
Explanation / Answer
please rate - thanks
#include <iostream>
#include <iomanip>
using namespace std;
void instructions();
double cost(double,double,double);
int main ()
{double house[3],fuel[3],rate[3],total[3];
int i;
instructions();
for(i=0;i<3;i++)
{cout<<"Enter the cost for house "<<i+1<<": ";
cin>>house[i];
cout<<"Enter the annual fuel cost for house "<<i+1<<": ";
cin>>fuel[i];
cout<<"Enter the tax rate for house "<<i+1<<": ";
cin>>rate[i];
total[i]=cost(house[i],fuel[i],rate[i]);
}
cout<<"Initial house cost Annual fuel cost Tax rate house cost ";
for(i=0;i<3;i++)
cout<<fixed<<"$"<<setprecision(0)<<house[i]<<" $"<<fuel[i]<<" "
<<setprecision(3)<<rate[i]<<" $"<<setprecision(0)<<total[i]<<endl;
system("pause");
return 0;
}
double cost(double h,double f,double r)
{double t;
t=h+f*5+(h*r)*5;
return t;
}
void instructions()
{cout<<"In shopping for a new house, you must consider several factors. "<<
"In this problem the initial cost of the house, estimated annual "<<
"fuel costs, and annual tax rate are available.You should be able "<<
"to inspect your program output to determine the "best buy". ";
}
Related Questions
drjack9650@gmail.com
Navigate
Integrity-first tutoring: explanations and feedback only — we do not complete graded work. Learn more.