Hey guys/gals have a question...my program wont output any information to the txt file that I have specified it just creates it but it leaves it blank :( . Here's the code hopefully someone can help me :)
thanks :)
#include <iostream>
#include<string>
#include<iomanip>
#include <fstream>
usingnamespace std;
class Carloan
{
private:
string applicantName;
string coApplicantName;
string applicantLastName;
string coApplicantLastName;
int creditScore1;
int creditScore2;
int months;
int numberOfApplicants;
double interest;
double downPayment;
double montlyPayment;
double totalIncome;
double vehicleSellingPrice;
double totalVehiclePrice;
double carTotalInterest;
double creditScore3;
public:
void Carloan::welcome();
int Carloan::applicantsInfo();
double Carloan::carAndCredit();
void Carloan::displayCarloanElig();
};
void Carloan::welcome()
{
cout << "Welcome to JB Carloan Financial" << endl;
cout << "Please follow the steps and enter the requiere amounts correct" << endl;
}
int Carloan::applicantsInfo()
{
cout << "Will there be one applicant or two?" << endl;
cin >> numberOfApplicants;
{
if (numberOfApplicants == 1)
{
cout << "Please enter the first and last name of the main Applicant " << endl;
cin >> applicantName >> applicantLastName;
cout << "Please enter the total income of the Applicant after all payments" << endl;
cin >> totalIncome ;
cout << "Please enter the credit score of the Applicant " << endl;
cin >> creditScore1 ;
}
else
{
cout << "Please enter the first and last name of the main Applicant " << endl;
cin >> applicantName >> applicantLastName;
cout << "Please enter the first and last name of the Co Applicant" << endl;
cin >> coApplicantName >> coApplicantLastName;
cout << "Please enter the total income of both applicants after all payments" << endl;
cin >> totalIncome ;
cout << "Please enter the credit score of the applicants" << endl;
cin >> creditScore1 ;
cout << "Please enter the credit score of the Co Applicant" << endl;
cin >> creditScore2 ;
cout << " " << endl;
creditScore3 = ((creditScore1 + creditScore2)/2);
}
}
}
double Carloan::carAndCredit()
{
if (numberOfApplicants == 1)
{
if ( creditScore1 < 500)
{
interest= .2599;
}
elseif ((creditScore1 >= 500) && (creditScore1 <=589))
{
interest= .1521;
}
elseif ((creditScore1 >= 590) && (creditScore1 <= 619))
{
interest= .1184;
}
elseif ((creditScore1 >= 620) && (creditScore1 <= 689))
{
interest = .8800;
}
elseif ((creditScore1 >= 690) && (creditScore1 <= 719))
{
interest = .5890;
}
else
{
interest= .3890;
}
}
else
{
if (creditScore3 < 499)
{
interest= .2599;
}
elseif ((creditScore3 >= 500) && (creditScore3 <=589))
{
interest= .1521;
}
elseif ((creditScore3 >= 590) && (creditScore3 <= 619))
{
interest= .1184;
}
elseif ((creditScore3 >= 620) && (creditScore3 <= 689))
{
interest = .8800;
}
elseif ((creditScore3 >= 690) && (creditScore3 <= 719))
{
interest = .5890;
}
else
{
interest= .3890;
}
}
cout << "Please enter the total price of the vehicle. " <<endl;
cin >> vehicleSellingPrice;
cout << "Please enter the number of months you wish to finance the car for " << endl;
cout << "The available months are 24, 36, 48, and 60." << endl;
cin >> months;
cout << "Will there be a downpayment? If not type 0." <<endl;
cin >> downPayment;
cout << " " << endl;
}
void Carloan::displayCarloanElig()
{
totalVehiclePrice = (vehicleSellingPrice - downPayment);
carTotalInterest = (totalVehiclePrice * interest);
montlyPayment = ((totalVehiclePrice / months) + (carTotalInterest/months));
if ((totalIncome - 400) > montlyPayment)
{
if (numberOfApplicants == 1)
cout << "We are please to inform that " << applicantName << " " << applicantLastName << " has been approved for the loan." << endl;
else
cout << "We are please to inform that " << applicantName <<" "<< applicantLastName << " and " << coApplicantName<<" " << coApplicantLastName << " have been approved for the loan." << endl;
cout << setprecision(2);
cout << "The estimated montly payments are: " << fixed << montlyPayment << " for " << months << " months." << endl;
cout << "We thank you for your business." << endl;
}
else
{
cout << "We are sorry at this time we cannot offer you with a loan. " << endl;
cout << "In 30 days you will recieve a letter stating why. Thank you." << endl;
}
}
int main()
{
ofstream outFile;
outFile.open("CarLoan.txt");
Carloan aCarloan;
aCarloan.welcome();
aCarloan.applicantsInfo();
aCarloan.carAndCredit();
aCarloan.displayCarloanElig();
outFile.close();
system("PAUSE");
return 0;
}