Question

C++ Please create the class named BankAccount with the following properties below: // The BankAccount class...

C++
Please create the class named BankAccount with the following properties below:

// The BankAccount class sets up a clients account (name & ID), keeps track of a user's available balance.
// It also keeps track of how many transactions (deposits and/or withdrawals) are made.
public class BankAccount {
    Private String name
    private String id;
    private double balance;
    private int numTransactions;

    // Please define method definitions for Accessors and Mutator functions below Private member variables
    string getName(); // No set method required.  It will be set using contructors
    int getId();      // No set method required.  It will be set using contructors
    double getBalance();  // No set Method required.  It will be initialized with constructor and then by Deposit method.
    int getNumTransactions(); 
    void setNumTransactions();  
    
    // Please create default constructor as well as parameterized Constructors - to create an object with the given name/id/balance and sets transactions to zero.
    public BankAccount(string name, int id, double balance);
    public BankAccount();
    // Other constructors....

    // Additional methods   
    // Deposit - Adds amount to balance. Also counts as 1 transaction.
    public void deposit(double amount)
    
    // Subtracts amount from balance if user has enough money. Counts as 1 transaction.
    public void withdraw(double amount)
    public void printOutput(); // This will output to screen, the account info: name/ID and balance and num transactions.
    
}

1) Please create the method definitions for the above methods within the BankAccount classs.  

For example:
BankAccount savings("John", 12345, 50.00);  // Creates an account with $50 initial deposit.  Note that numTransactions should be set to zero as well.

savings.deposit(10.00);
savings.deposit(50.00);
savings.deposit(10.00);
savings.deposit(70.00);         
savings.withdraw(100.00);
Account info: John, 12345 has  aBalance = $90, with 5 transactions

3) Please test all methods with different inputs.  You can put all of the test data screenshots in a word document.  
4) Please add comments as appropriate, and use good coding styles and naming conventions as has been discussed in class.
5) This assignment is to be worked on individually and not in groups.
6) You should upload to BB - the C++ file and one word file with all the screenshots showing the different test runs with different test data.
0 0
Add a comment Improve this question Transcribed image text
Answer #1

Note: Could you plz go through this code and let me know if u need any changes in this.Thank You
_________________

#include <fstream>
#include <iostream>
#include <iomanip>
#include <cstring>
#include <cstdlib>
using namespace std;

class BankAccount {
private :
   string name;
int id;
double balance;
int numTransactions;
public :
// Please define method definitions for Accessors and Mutator functions below Private member variables
string getName() // No set method required. It will be set using contructors
{
   return name;
   }
int getId() // No set method required. It will be set using contructors
{
   return id;
   }
double getBalance() // No set Method required. It will be initialized with constructor and then by Deposit method.
{
   return balance;
   }
int getNumTransactions()
{
   return numTransactions;
   }
void setNumTransactions()
   {
       numTransactions=0;
   }
  
// Please create default constructor as well as parameterized Constructors - to create an object with the given name/id/balance and sets transactions to zero.
BankAccount(string name, int id, double balance)
{
   this->name=name;
   this->id=id;
   this->balance=balance;
   setNumTransactions();
   }
   // Other constructors....
BankAccount()
{
   this->name="";
   this->id=0;
   this->balance=0.0;    
   setNumTransactions();
   }
  

// Additional methods   
// Deposit - Adds amount to balance. Also counts as 1 transaction.
void deposit(double amount)
{
   this->balance+=amount;
   numTransactions++;
   }
  
// Subtracts amount from balance if user has enough money. Counts as 1 transaction.
void withdraw(double amount)
{
   if(amount<=balance)
   {
       this->balance-=amount;
       numTransactions++;
       }
   }
void printOutput() // This will output to screen, the account info: name/ID and balance and num transactions.
{
   cout<<"Account Info : "<<name<<", "<<id<<" has a Balance = $"<<balance<<", with "<<numTransactions<<" transactions"<<endl;
   }
  
};

int main() {
   //Declaring variables
BankAccount savings("John", 12345, 50.00); // Creates an account with $50 initial deposit. Note that numTransactions should be set to zero as well.

savings.deposit(10.00);
savings.deposit(50.00);
savings.deposit(10.00);
savings.deposit(70.00);   
savings.withdraw(100.00);

savings.printOutput();
  
   return 0;
}

_________________________

Output:

_______________Could you plz rate me well.Thank You

Add a comment
Know the answer?
Add Answer to:
C++ Please create the class named BankAccount with the following properties below: // The BankAccount class...
Your Answer:

Post as a guest

Your Name:

What's your source?

Earn Coins

Coins can be redeemed for fabulous gifts.

Not the answer you're looking for? Ask your own homework help question. Our experts will answer your question WITHIN MINUTES for Free.
Similar Homework Help Questions
  • Write a Java class called BankAccount (Parts of the code is given below), which has two...

    Write a Java class called BankAccount (Parts of the code is given below), which has two fields name (String) and balance (double), two constructors and five methods getName(), getBalance(), deposit (double amount), withdraw(double amount) and toString(). The first constructor should initialize name to null and balance to 0. The second constructor initializes name and balance to the parameters passed. deposit method deposits the amount to the account causing the current balance to increase, withdraw method withdraws the amount causing the...

  • Write a Java class called BankAccount (Parts of the code is given below), which has two...

    Write a Java class called BankAccount (Parts of the code is given below), which has two fields name (String) and balance (double), two constructors and five methods getName(), getBalance(), deposit (double amount), withdraw(double amount) and toString(). The first constructor should initialize name to null and balance to 0. The second constructor initializes name and balance to the parameters passed. deposit method deposits the amount to the account causing the current balance to increase, withdraw method withdraws the amount causing the...

  • TASK 1 Create a new class called CheckingAccount that extends BankAccount. It should contain a static...

    TASK 1 Create a new class called CheckingAccount that extends BankAccount. It should contain a static constant FEE that represents the cost of clearing onecheck. Set it equal to 15 cents. Write a constructor that takes a name and an initial amount as parameters. Itshould call the constructor for the superclass. It should initializeaccountNumber to be the current value in accountNumber concatenatedwith -10 (All checking accounts at this bank are identified by the extension -10). There can be only one...

  • c++ please    Define the class bankAccount to implement the basic properties of a bank account....

    c++ please    Define the class bankAccount to implement the basic properties of a bank account. An object of this class should store the following data: Account holder’s name (string), account number (int), account type (string, checking/saving), balance (double), and interest rate (double). (Store interest rate as a decimal number.) Add appropriate member func- tions to manipulate an object. Use a static member in the class to automatically assign account numbers. Also declare an array of 10 compo- nents of...

  • Implement a class Portfolio. This class has two objects, checking and savings, of the type BankAccount....

    Implement a class Portfolio. This class has two objects, checking and savings, of the type BankAccount. Implement four methods: • public void deposit(double amount, String account) • public void withdraw(double amount, String account) • public void transfer(double amount, String account) • public double getBalance(String account) Here the account string is "S" or "C". For the deposit or withdrawal, it indicates which account is affected. For a transfer, it indicates the account from which the money is taken; the money is...

  • java code ========= public class BankAccount { private String accountID; private double balance; /** Constructs a...

    java code ========= public class BankAccount { private String accountID; private double balance; /** Constructs a bank account with a zero balance @param accountID - ID of the Account */ public BankAccount(String accountID) { balance = 0; this.accountID = accountID; } /** Constructs a bank account with a given balance @param initialBalance the initial balance @param accountID - ID of the Account */ public BankAccount(double initialBalance, String accountID) { this.accountID = accountID; balance = initialBalance; } /** * Returns the...

  • java code ============= public class BankAccount { private String accountID; private double balance; /** Constructs a...

    java code ============= public class BankAccount { private String accountID; private double balance; /** Constructs a bank account with a zero balance @param accountID - ID of the Account */ public BankAccount(String accountID) { balance = 0; this.accountID = accountID; } /** Constructs a bank account with a given balance @param initialBalance the initial balance @param accountID - ID of the Account */ public BankAccount(double initialBalance, String accountID) { this.accountID = accountID; balance = initialBalance; } /** * Returns the...

  • In C++ Write a program that contains a BankAccount class. The BankAccount class should store the...

    In C++ Write a program that contains a BankAccount class. The BankAccount class should store the following attributes: account name account balance Make sure you use the correct access modifiers for the variables. Write get/set methods for all attributes. Write a constructor that takes two parameters. Write a default constructor. Write a method called Deposit(double) that adds the passed in amount to the balance. Write a method called Withdraw(double) that subtracts the passed in amount from the balance. Do not...

  • C++ Design a class bankAccount that defines a bank account as an ADT and implements the...

    C++ Design a class bankAccount that defines a bank account as an ADT and implements the basic properties of a bank account. The program will be an interactive, menu-driven program. a. Each object of the class bankAccount will hold the following information about an account: account holder’s name account number balance interest rate The data members MUST be private. Create an array of the bankAccount class that can hold up to 20 class objects. b. Include the member functions to...

  • [JAVA] < Instruction> You are given two classes, BankAccount and ManageAccounts ManageAccounts is called a Driver...

    [JAVA] < Instruction> You are given two classes, BankAccount and ManageAccounts ManageAccounts is called a Driver class that uses BankAccount. associate a member to BankAcount that shows the Date and Time that Accounts is created. You may use a class Date. To find API on class Date, search for Date.java. Make sure to include date information to the method toString(). you must follow the instruction and Upload two java files. BankAccount.java and ManageAccounts.java. -------------------------------------------------------------------------- A Bank Account Class File Account.java...

ADVERTISEMENT
Free Homework Help App
Download From Google Play
Scan Your Homework
to Get Instant Free Answers
Need Online Homework Help?
Ask a Question
Get Answers For Free
Most questions answered within 3 hours.
ADVERTISEMENT
ADVERTISEMENT
ADVERTISEMENT