Question
c++ and please add tables and everything and make sure program is complete.
Write a menu driven program, which would compute compound interest and a monthly payment for a loan. The user will be given a
0 0
Add a comment Improve this question Transcribed image text
Answer #1

//do comment if any problem arises

//code should be something like

#include <iostream>

#include <cmath>

#include <string>

#include <fstream>

using namespace std;

//this funciton returns choise of user

int menu()

{

cout << "\nEnter (1) to calculate your loan monthly payment";

cout << "\nEnter (2) to calculate your loan monthly payment & write to a file\n";

int choise;

cin >> choise;

//invalid choise

if (choise != 1 && choise != 2)

return menu();

return choise;

}

//this function caculates monthly payment

double calculate_monthly_payment(double P, double r, int t)

{

double A;

A = P * pow(1 + r, t);

A /= t;

return A / 12;

}

int main()

{

string filename = "output.txt";

ofstream outfile(filename, ios::app);

int choise = menu();

string name, Address, Phone;

//principal amount

double P, fixed_monthly_payment,r;

//interest rate

int t;

//read Borrower's name

cout << "Borrower's Name: ";

cin.ignore();

getline(cin, name);

//read Borrower's address

cout << "Borrower's Address: ";

cin.ignore();

getline(cin, Address);

//read Borrower's phone

cout << "Borrower's Phone number: ";

cin.ignore();

getline(cin, Phone);

cout << "Loan Amount: ";

cin >> P;

//read interest rate

cout << "Interest Rate (APR): ";

cin >> r;

r/=100;

//read number of years

cout << "Number of years the amount is deposited or borrowed for: ";

cin >> t;

fixed_monthly_payment = calculate_monthly_payment(P, r, t);

cout << "Fixed Monthly payment for your loan is: " << fixed_monthly_payment;

if (choise == 2)

{

outfile << "Borrower's Name: " << name << endl;

outfile << "Borrower's Address: " << Address << endl;

outfile << "Borrower's Phone: " << Phone << endl;

outfile << "Loan Amount: " << P << endl;

outfile << "Interest Rate: " << r << endl;

outfile << "Fixed Monthly Payment: " << fixed_monthly_payment << endl;

}

outfile.close();

}

Output:

Enter (1) to calculate your loan monthly payment Enter (2) to calculate your loan monthly payment & write to a file 2 Borrowe

Output file output.txt:

output.txt Borrowers Name: Rohit Shetty Borrowers Address: BJ nagar delhi 1 2 Borrowers Phone: 6446xxxxx 33 4 Loan Amount:

Add a comment
Know the answer?
Add Answer to:
c++ and please add tables and everything and make sure program is complete. Write a menu...
Your Answer:

Post as a guest

Your Name:

What's your source?

Earn Coins

Coins can be redeemed for fabulous gifts.

Not the answer you're looking for? Ask your own homework help question. Our experts will answer your question WITHIN MINUTES for Free.
Similar Homework Help Questions
  • Java Programming----- Creating a Mortgage Calculator Program

    Write the program in Java (with a graphical user interface) and have it calculate and display the mortgage payment amount from user input of the amount of the mortgageand the user's selection from a menu of available mortgage loans:•7 years at 5.35%•15 years at 5.5%•30 years at 5.75%Use an array for the mortgage data for the different loans. Read the interest rates to fill the array from a sequential file. Display the mortgage payment amountfollowed by the loan balance and...

  • Write a contacts database program that presents the user with a menu that allows the user...

    Write a contacts database program that presents the user with a menu that allows the user to select between the following options: (In Java) Save a contact. Search for a contact. Print all contacts out to the screen. Quit If the user selects the first option, the user is prompted to enter a person's name and phone number which will get saved at the end of a file named contacts.txt. If the user selects the second option, the program prompts...

  • Program Specification: This project involves implementing a Java program that performs a calculation of payments associated...

    Program Specification: This project involves implementing a Java program that performs a calculation of payments associated with loans. The program shall allow a user to enter the following data: annual interest rate the loan (i.e. , number of years), and the loan amount. A GUI like the one below must be used. Loan Calculator Annual Interest Rate: Number of Years Loan Amount: Monthly Payment Total Payment Calculate When the user presses the calculate button, the monthly payment and total amount...

  • In C. Thank you! Bank Write a program to calculate the monthly payment on a loan...

    In C. Thank you! Bank Write a program to calculate the monthly payment on a loan given the loan amount, interest rate and the number of years to pay off the loan. Then add a function to print an amortization schedule for that loan. Create a class to save the current balance and the rest of the data as private data. Add member functions to make a payment and to print the amortization report. Use the following class header. Class...

  • Write a python program for the below question? Car Loan If A dollars is borrowed at...

    Write a python program for the below question? Car Loan If A dollars is borrowed at r% interest compounded monthly to purchase a car with monthly payments for n years, then the monthly payment is given by the formula monthly payment = i / 1 - (1 + i)-12n . A where i = r/1200. Write a program that calculates the monthly payment after the user gives the amount of the loan, the interest rate, and the number of years.

  • The program is in python :) Write a code program to calculate the mortgage payment. The...

    The program is in python :) Write a code program to calculate the mortgage payment. The equation for calculating the mortgage payment is: M = P (1+r)n (1+r)n-1 Where: M is your monthly payment P is your principal r is your monthly interest rate, calculated by dividing your annual interest rate by 12. n is your number of payments (the number of months you will be paying the loan) Example: You have a $100,000 mortgage loan with 6 percent annual...

  • PYTHON ONLY PLEASE (Financial application: compare loans with various interest rates) Write a program that lets...

    PYTHON ONLY PLEASE (Financial application: compare loans with various interest rates) Write a program that lets the user enter the loan amount and loan period in number of years and displays the monthly and total payments for each interest rate starting from 5% to 8%, with an increment of 1/8. Sample Run Loan Amount: 10000 Number of Years: 5 Interest Rate Monthly Payment Total Payment 5.000% 188.71 11322.74 5.125% 189.29 11357.13 5.250% 189.86 11391.59 ... 7.875% 202.17 12129.97 8.000% 202.76...

  • Please make a JAVA program for the following using switch structures Write a program that simulates...

    Please make a JAVA program for the following using switch structures Write a program that simulates a simple Calculator program. The program will display menu choices to the user to Add, Subtract, Multiply and Divide. The program will prompt the user to make a selection from the choices and get their choice into the program. The program will use a nested if….else (selection control structure) to determine the user’s menu choice. Prompt the user to enter two numbers, perform the...

  • THE PROBLEM: The nice folks from the Lion Lending Company have hired you to write some...

    THE PROBLEM: The nice folks from the Lion Lending Company have hired you to write some software that will process their daily loan information. The data will come from a text file that has the following format: The first line will contain an integer: number of loan applications There will be two rows for each of the customers First line will be the customer's (1) first name and (2) last name, separated by a space (assume there is no spaces...

  • 14.Compound Interest hank account pays compound interest, it pays interest not only on the principal amount...

    14.Compound Interest hank account pays compound interest, it pays interest not only on the principal amount that was deposited into the account, but also on the interest that has accumulated over time. Suppose you want to deposit some money into a savings account, and let the account earn compound interest for a certain number of years. The formula for calculating the balance of the account afer a specified namber of years is The terms in the formula are A is...

ADVERTISEMENT
Free Homework Help App
Download From Google Play
Scan Your Homework
to Get Instant Free Answers
Need Online Homework Help?
Ask a Question
Get Answers For Free
Most questions answered within 3 hours.
ADVERTISEMENT
ADVERTISEMENT
ADVERTISEMENT