Solved

# Can anyone tell me what is wrong with my program in order for it to work in c++?

Posted on 2006-03-20

/*

Program Calculator Week3 Individual Assignment

Version 2.2

Date: March 17, 2006

Display the amount of monthly payment amount for a mortgage payment enter by user to display loan amount, interest rate, and term of loan.

*/

#include <math.h>

#include <string>

#include <iostream>

using namespace std

int main()

{

// Set variables use for mortgage payment

double amount; // Loan amount

int term; // Loan term

int month = 12; // 1 year = 12 months

int term_months; // Loan term in month

double rate; // Loan interest rate

int choice; // Used for choice dialog

double monthly_payment; // Variable for monthly payment

double term_rate; // Holds percentage as a decimal

cout << "Enter the loan amount in dollars: ";

cin >> amount;

cout << "Enter the loan term in years: ";

cin >> term;

cout << "Enter the interest rate as a percentage: ";

cin >> rate;

term_months = (term*12); //Converts years to months

term_rate = (rate/100); // Converts Percentage to Decimal

double amortization_factor = 1 + (rate / 100 / 12);

monthly_payment = amount * (amortization_factor - 1.0) / (1.0 - pow(amortization_factor, -term_months));

cout << "Your Mortgage amount is\n";

cin << "Amount: $ " << amount << endl; //Prints out Amount

cout << "Your Mortgage is being taken out for" << endl;

cin << "Years: " << term << endl; //Prints out Term

cout << "The interest rate is\n";

cin << "Percent: " << rate << endl; //Prints out Rate

cout << "Your Monthly Payment Amount is " << endl;

cin << "Payment Amount: $ " << monthly_payment <<endl; //Prints out monthly payment

//Allows the user to end or start over

char ans;

do

{

cout<< "Do you want to continue (Y/N)?\n";

cout<< "You must type a 'Y' or an 'N'.\n";

cin >> ans;

}

while((ans !='Y')&&(ans !='N')&&(ans !='y')&&(ans !='n'));

/*the loop continues until the user enters the correct response*/