Answer to Question #319220 in C++ for Vazu

Question #319220

Input:

staff name, the amount of loan, Year of Installment = 2 Process:

Do the decision

if (amount of loan < 5 000)

interest = 2

else if ( 10 000 < amount of loan >= 5 000)

interest = 2.5 else

Display “Invalid input. The maximum amount is RM10000”

interest = 0 Calculate Total of Interest

= (interest/100) * amount of loan

Calculate the Total Loan with Interest = amount of loan + Total of Interest

Calculate the monthly installment

= Total Loan with Interest / (Year of Installment * 12)

Output:

staff name, the amount of loan, monthly installment.


1
Expert's answer
2022-03-27T16:36:22-0400
#include <iostream>
#include <iomanip>
#include <string>
using namespace std;


int main() {
    string name;
    double loan;
    double interest;
    int years = 2;


    cout << "Enter staff name: ";
    getline(cin, name);
     cout << "Enter the amount of loan: ";
     cin >> loan;


    if (loan < 5000) {
        interest = 2;
    }
    else if ( loan < 10000) {
        interest = 2.5;
    }
    else {
        cout << "Invalid input. The maximum amount is RM10000" << endl;
        interest = 0;
    }


    double tot_interest = (interest/100) * loan;
    double loan_with_interest = loan + tot_interest;
    double monthly_installment = loan_with_interest / (years * 12);


    cout << "Staff name: " << name << endl;
    cout << fixed << setprecision(2);
    cout << "The amount of loan: RM" << loan << endl;
    cout << "The monthly installment: RM" << monthly_installment;


    return 0;
}

Need a fast expert's response?

Submit order

and get a quick answer at the best price

for any assignment or question with DETAILED EXPLANATIONS!

Comments

No comments. Be the first!

Leave a comment

LATEST TUTORIALS
New on Blog