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

Write the following c++ program. Design a class named Account that contains: A f

ID: 3696150 • Letter: W

Question

Write the following c++ program.

Design a class named Account that contains: A field named ID (inf) A field named omner Name. (string) A field named interestRate (double) representing the monthly interest rate A field named balance (double)  Accessorand Mutator functionsfor ID; ownerName. interestRate and balance fields. A function named   getAnnualInterest() that    returns    the    annual    interest    rate. A function named withdraw() that withdraws a specified amount (given as an argument) from the account. 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 that the 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 ownerName. Make two withdrawals, one of them with no sufficient balance, and two deposits. After each opersion, the program should obtain the remaining balance and print the annual interest: rate.

Explanation / Answer

#include<iostream>
#include<conio>
#include<string>

using namespace std;

class Account
{
public:
   int ID;
   string ownerName;
   double interestRate, balance;

   void setID(int i)
   {
       ID=i;
   }

   void setownname(string on)
   {
       strcpy(ownerName,on);
   }

   void setintrate(double ir)
   {
       interestRate=ir;
   }

   void setbal(double b)
   {
       balance=b;
   }

   int getID()
   {
       return ID;
   }

   string getownname()
   {
       return ownerName;
   }

   double getintrate()
   {
       return interestRate;
   }

   double getbal()
   {
       return balance;
   }

   double getAnnualInterest()
   {
       return balance*0.35;
   }

   void withdraw(double amt)
   {
       if(amt<0)
           cout<<"Amount can't be negative";
       else if(balance<amt)
           cout<<"Insufficient Balance";
       else
           balance=balance-amt;
   }

   void deposit(double amt)
   {
       if(amt<0)
           cout<<"Amount can't be negative";
       else
           balance=balance+amt;
   }

};

void main()
{
   double b;

   Amount o;

   o.setID(7497);
   o.setownname("ABC");
   o.setintrate(0.35);
   o.setbal(30000);

   o.withdraw(40000);
   o.withdraw(10000);
   b=o.getbal();
   cout<<"Current Balance="<<b<<endl;
   cout<<"Annual Interest ="<<o.getAnnualInterest();

   o.deposit(-40000);
   o.deposit(10000);
   b=o.getbal();
   cout<<"Current Balance="<<b<<endl;
   cout<<"Annual Interest ="<<o.getAnnualInterest();

   getch();
}