**Unformatted text preview:**

SpongeBob & Co BankProject 1Name: Arvind RajStudent ID: 0323797Subject: CSCI 102Lecturer’s Name: Miss ChandraSPONGEBOB & Co Bank Problem Definition:To create a program for SpongeBob & Co Bank to calculate the monthly payable amount of a loan using the mortgage amount, the mortgage term and the yearly interest rate of the mortgage The following formulas were used in this program:Months = MTerm*12TIRate = (MTerm*IRate)/100TIRateP = MTerm*IRatePinterest = TIRate*MAmountGAmount = PInterest+MAmountMPayment = GAmount/MonthsAnalysis:InputThe amount of loanThe loan termThe interest rate in percentageProcessMonths = MTerm*12TIRate = (MTerm*IRate)/100TIRateP = MTerm*IRatePInterest = TIRate*MAmountGAmount = PInterest+MAmountMPayment = GAmount/MonthsOutputThe monthly payable amountThe total gross amountThe total payable interest amountThe total interest rateCodes:// Name: Arvind Raj// Student ID: 0323797// Project 1: A program that calculates the monthly payable amount of a loan.// CSCI 102// SpongebobMortgage.cpp : Defines the entry point for the console application.#include <iostream> // library funtion to prompt input and outputusing namespace std;int main(){ // variables declaration double MAmount; // the amount which is borrowed by the user double MTerm; // the number of years the user has to pay back the borrowed amount double Months; // the number of months for user to pay the payments double IRate; // the interest that is charged yearly double TIRate; // the total interest among the years double TIRateP; // the total interest rate percentage double PInterest; // the amount of interest needed to be paid double GAmount; // total payment the user has to pay double MPayment; // the monthly payment of the user cout << "SpongeBob and Co Bank mortgage calculator " "\n\n"; // display message cout << "Please fill in the following details\n\n"; // display message cout << "The amount of loan which is borrowed (RM) \n:"; // prompt data from user cin >> MAmount; // read value as MAmountcout << "How long is the loan term in years? \n:"; // prompt data for user cin >> MTerm; // read value as MTerm cout << "How much is the interest rate of the loan? (%) \n:"; // prompt user fordata cin >> IRate; // read value as IRate Months = MTerm*12; // formula to find the number of months of the loan term TIRate = (MTerm*IRate)/100; // formula to calculate the total interest rate of the loan term TIRateP = MTerm*IRate; // formula to calculate total interest rate percentage PInterest = TIRate*MAmount; // formula to calculate the payable interest amount of the loan term GAmount = PInterest+MAmount; // formula to calculate the total payable amount of the loan MPayment = GAmount/Months; // formula to calculate the amount needed to be paid monthly during the loan term cout << "_________________________________________________________\n\n" ; // display lines cout << "The borrowed amount for the loan is RM " << MAmount << "\n"; // the borrowed amount for the loan cout << "_________________________________________________________\n\n" ; // display lines cout << "Your loan term is for " << MTerm << " years\n"; // the number of years of the loan term cout << "_________________________________________________________\n\n"; // display lines cout << "Your yearly interest rate is " << IRate << "%\n"; // the yearly interest rate of the loan cout << "_________________________________________________________\n\n"; // display lines cout << "Your total interest rate across the loan term is " << TIRateP << "%\n"; // the total interest rate depending on years cout << "_________________________________________________________\n\n"; // display lines cout << "Your total payable interest is RM " << PInterest << "\n"; // total payable interest amount of the loan cout << "_________________________________________________________\n\n"; // display lines cout << "Your gross payable amount of the loan is RM " << GAmount << "\n"; // the total gross amount of the loan cout << "_________________________________________________________\n\n"; // display lines cout << "Your monthly payable amount is RM " << MPayment << "\n"; // the monthly payable amount of the loan cout << "_________________________________________________________\n"; // display lines cout << "\n\n"; // spaces cout << "Thank you for using SpongeBob and Co Bank mortgagecalculator.\n"; // display message cout << endl; // end line

View Full Document