Answer to Question #330770 in C++ for Steve

Question #330770

Question :Create a class Account with the following private member variablesData TypeVariable Namechar[]accountNumberdoubleamountchar[]accountHolderUse appropriate Get and Put function to get and display the values for  Account classCreate a function calc()  to calculate the interest amount as interest_amount=amount*n*r/100, where n is fixed as 5 and r as 3

1
Expert's answer
2022-04-19T08:07:07-0400
#include <iostream>
using namespace std;

class Account {
    char accountNumber[15];
    double amount;
    char accountHolder[32];

public:
    void Get();
    void Put();
    double calc();
};

void Account::Get() {
    cout << "Enter an account Number: ";
    cin.getline(accountNumber, sizeof(accountNumber));
    cout << "Enter an account Holder: ";
    cin.getline(accountHolder, sizeof(accountHolder));
    cout << "Enter an account amount: ";
    cin >> amount;
}

void Account::Put() {
    cout << "Account Number: " << accountNumber << endl;
    cout << "Accoutn Holder: " << accountHolder << endl;
    cout << "Account amount: $" << amount << endl;
}


double Account::calc() {
    const int n = 5;
    const int r = 3;
    double interest_amount;


    interest_amount = amount * n * r / 100;
    amount += interest_amount;
    return interest_amount;
}


int main() {
    Account account;

    account.Get();
    cout << endl;
    account.calc();
    account.Put();

    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
APPROVED BY CLIENTS