Academic Integrity: tutoring, explanations, and feedback — we don’t complete graded work or submit on a student’s behalf.

In C++, write a program that obeys the pictured criteria. At end, pause output w

ID: 3695786 • Letter: I

Question

In C++, write a program that obeys the pictured criteria. At end, pause output with cin get(); and cin ignore();

Design a class named Account that contains A field named ID (int) A field named ownerName (string) A field named interestRate (double) representing the monthly interestrate A field named balance (double) Accessor and Mutator functions forD. owner fields . . . ame. InterestRate and balance . A function named getAnnualInterest ) that retums the annual interestrate . A function named withdrawl)that withdraws a specified amount (givenas an argument) from theaccount. The function verifies that the amount is positive and that there are sufficient funds in the account and issues an error message if these conditions are not met. The function updates the remaining balance accordingly . A function named deposit) that deposits a specified amount (given as an argument) to the account. The function verifies thatthe amount is positive and issues an error message if it isn't. The function updates the remaining balance accordingly Write a test program that creats an account and assigns its ID to 7497, its balance to 30000 and its monthly interest rate to 0.35%. Use your name as the owner:Name Make two withdrawals, one of them with no sufficient balance, and two deposits. After each operation, the program should obtain the remaining balance and print the annual interest rate

Explanation / Answer

// Example program
#include <iostream>
#include <string>

using namespace std;

class Account
{
public:
int id;
string ownerName;
double interestRate, balance;
  
void setID(int i){
id=i;
}
void setOwnerName(string name){
ownerName = name;
}
void setInterestRate(double in){
interestRate = in;
}
void setBalance(double b){
balance = b;
}
  
int getID(){
return id;
}
string getOwnerName(){
return ownerName;
}
double getInterestRate(){
return interestRate ;
}
  
double getBalance(){
return balance;
}
  
void withdraw(double amt){
if(amt<0)
cout << "Invalid amount" << endl;
else if(amt > balance)
cout << "No sufficient amount" << endl;
else{
balance = balance - amt;
}
}

void deposit(double amt){
if(amt<0)
cout << "Invalid amount" << endl;
else{
balance = balance + amt;
}
}
  
};


int main()
{
Account acc;
  
acc.setID(7497);
acc.setOwnerName("Mr.X");
acc.setBalance(30000);
acc.setInterestRate(0.35);
  
acc.withdraw(-400);
cout << "Balance:" << acc.getBalance() << endl;

acc.withdraw(2500);
cout << "Balance:" << acc.getBalance() << endl;

acc.deposit(500);
cout << "Balance:" << acc.getBalance() << endl;

cout << "Annula interest rate:" << acc.getInterestRate()*12*acc.getBalance() << endl;
}