Here is a copy of my program:
In the final output it shows that the total months it would take for the person to purchase the house would be 109,202 and the left over value in the final month is $240,000 (the original price of the house)Code:#include <iostream> using namespace std; int main() { double initial_amount; // beginning amount $240,000 double interest_rate6; // 6% interest applied double interest_rate7; // 7% interest applied int monthly_payment; // amount paid each month $1500 int payment_period; // 12 months per year int total_months; // total number of months to pay for house double down_payment; //$40,000 double loan_balance; // amount currently owed double payment_amount; // how much has been paid total double years; // years double left_over; //amount left over cout << "Enter the initial price of the house (eg. xxxxxx.xx): "; cin >> initial_amount; cout << "Enter the down payment for the house (eg. xxxxx.xx): "; cin >> down_payment; cout << "Enter the annual interest rate for the first 3 years in decimal form (6% equals 1.06 eg. x.xx): "; cin >> interest_rate6; cout << "Enter the annual interest rate following the first 3 years in decimal form (7% equals 1.07 eg. x.xx): "; cin >> interest_rate7; cout << "Enter your monthly payment (eg. xxxx.xx): "; cin >> monthly_payment; cout << "Enter the amount of annual payment periods (if once a month, press 12): "; cin >> payment_period; loan_balance = (initial_amount - down_payment) - (monthly_payment*payment_period); years = payment_period*12; while (payment_amount > loan_balance) { if (years > 3) { loan_balance = (payment_amount*interest_rate6) - loan_balance; } else loan_balance = (loan_balance*interest_rate7) - loan_balance; } left_over = initial_amount - payment_amount; total_months = (loan_balance/monthly_payment)/12; cout.setf(ios::fixed); cout.setf(ios::showpoint); cout.precision(2); cout << "It will take you " << total_months <<" months to purchase the house." << endl; cout << "The final monthly payment for your house is $" << left_over << endl; return 0; }
I must be going crazy, but I cannot put my finger on these simple logical errors. Thanks!



LinkBack URL
About LinkBacks


