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
|
#include <fstream>
#include <iostream>
#include <iomanip>
using namespace std;
void getinput (int&, float & , float & , float & );
void autoloan (double , double , double , bool&);
void mortgage (double , double , double loanamount, bool& );
void printreport (int , double, bool& );
void getinput (int&loantype, float & income, float & totaldebt, float & loanamount)
{
cout<<"Select one of the following options: "<<endl<<endl;
cout<<" 1 Auto Loan"<<endl;
cout<<" 2 Mortgage "<<endl;
cout<<" 3 Stop program"<<endl<<endl;
cout<<" Enter a number ";
cin>>loantype;
if (loantype==1||loantype==2)
{
cout<<"Enter income, total debt, and loan amount"<<endl;
cin>>income>>totaldebt>>loanamount;
}
}
void autoloan (double income, double totaldebt, double loanamount, bool& eligible)
{
if(income-totaldebt>=loanamount*.5)
eligible=true;
else (eligible=false);
}
void mortgage (double income, double totaldebt, double loanamount, bool& eligible)
{
if(income-totaldebt>=loanamount*.3)
eligible=true;
else (eligible=false);
}
void printreport (int loantype, double loanamount, bool& eligible)
{
cout<<"Aprroved for loan?"<<eligible<<endl;
cout<<"Type of loan approved for "<<loantype<<endl;
cout<<"In the amount of "<<loanamount<<endl;
}
int main ()
{
double income;
double totaldebt;
double loanamount;
bool eligible;
int loantype;
//Do intializations
while (loantype!=3);
{
getinput (loantype ,income, totaldebt,loanamount);
if (loantype==1)
{
autoloan(income, totaldebt, loanamount, eligible);
printreport (loantype, loanamount, eligible);
}
else if (loantype==2)
{
mortgage (income, totaldebt, loanamount, eligible);
printreport (loantype, loanamount, eligible);
}
}
}
|