Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

Code in C++ Modify the following code by adding an input function and output formatting function in accordance with the requirements below. The functions do

Code in C++

Modify the following code by adding an input function and output formatting function in accordance with the requirements below. The functions do not have to be part of the class.

image text in transcribed

Code that need to be modified!

#include #include class Loanpayment {public: void setloanamount(double); void setrate(double); void setyears(double); double paymentcalculator(void); double totalpayment(double); private: double rate, loan, years; }; int main() {Loanpayment x; double value,payment,totalpaid,y; cout.setf(ios::fixed,ios::floatfield); cout.precision(2); cout>value; x.setloanamount(value); cout>value; x.setrate(value); cout>y; x.setyears(y); payment=x.paymentcalculator(); cout

void Loanpayment::setloanamount(double n) {loan=n; }

void Loanpayment::setyears(double n) {years=n; }

doubleLoanpayment::paymentcalculator() {double term,payment; term=(1.+pow((rate/12.),12*years)); payment=(loan*rate/12.*term)/term-1.; return payment; }

doubleLoanpayment::totalpayment(double p) {return p*(12.*years); }

1. 2. 3. 4. 5. 6. 7. 8. 9. Limit the maximum Loan Amount to $100,000.00 Accept the interest rate (4.5% as 4.5), and limit the interest rate to 22% maximum Limit the Loan Duration to 6 years (using whole years) Validate all input values for any error (non-digit, zero or negative values, etc.) Echo the inputs with titles and the formatting specified in 6 and 7 Add commas to the output values for thousands, and millions. Add a percent sign for the interest rate Left align the titles, and right align the values Space everything for alignment as shown ferences: char[l, string, sprint, cin.fail(), cin.clear(), system("CLS") EABCC Spring 20181CSE 111 New BookLabs and Solutions CSE 111 NEWL0 Enter the amount of the loan: 12345.67 Enter the annual interest rate (example 3 3%): 2.5 Enter the Duration of the Loan in years:6 Loan amount: Interest Rate: Duration (years) Monthly Payment: Total Payback Amount: Total Interest Paid-in: $12,345.67 2.50% 6 $184.83 $13,307.57 $961.90 Enter "V" to compute another loan

Step by Step Solution

There are 3 Steps involved in it

Step: 1

blur-text-image

Get Instant Access to Expert-Tailored Solutions

See step-by-step solutions with expert insights and AI powered tools for academic success

Step: 2

blur-text-image

Step: 3

blur-text-image

Ace Your Homework with AI

Get the answers you need in no time with our AI-driven, step-by-step assistance

Get Started

Recommended Textbook for

Databases Organizing Information Digital And Information Literacy

Authors: Greg Roza

1st Edition

1448805929, 978-1448805921

More Books

Students also viewed these Databases questions