Question

Either know this is just a homework assignment please if you dont know the answer or...

Either know this is just a homework assignment please if you dont know the answer or if you dont check that its right please dont work on this serious answers only please and thank you and no java only visual studio c++ please.

Q1 : Classes and Objects 1. Create a class definition for an object called Account. Add a constructor and destructor to it. 2. Add 2 internal data member of char or string type which should be named firstName and lastName. 3. Then add two methods debitFrom which takes a double as a call parameter and creditTo which also takes a double data type. 4. Add an internal to the Account class called currentBalance of type double. 5. Instantiate an object of type Account with a starting balance of $100.00 belonging to a customer by the name of John Smith 6. Show how you would create const members functions in this class – what is the benefit of such member functions.

0 0
Add a comment Improve this question Transcribed image text
Answer #1

//Account.cpp

//include header files for basic io operations

#include<iostream>
#include<string>
using namespace std;

class Account
{
private:
   string firstName;
   string lastName;
   double currentBalance;
public:

   Account()
   {
       firstName="NA";
       lastName="NA";
       currentBalance=0;
   }

   Account(string fName, string lName, double bal)
   {
       firstName=fName;
       lastName=lName;
       currentBalance=bal;
   }

   /*constant member functions
   for the private data of account class
   const member functions guarantees that the
   private data is not midifiable
   */
   string getFirstName() const
   {
       return firstName;
   }
   string getLastName() const
   {
       return lastName;
   }
   double getCurrentBalance() const
   {
       return currentBalance;
   }

   /* member function to debit
   from current balance*/
   void debitFrom(double amt)
   {
       currentBalance-=amt;
   }
   /*member function to credit amount
   to current balance*/
   void creditTo(double amt)
   {
       currentBalance+=amt;
   }
};//end of Account class


int main()
{

   //5.Instantiate the Account class object
   Account act("John","Smith",100);

   cout<<"Account Name :"<<act.getFirstName()
       <<" "<<act.getLastName()<<endl;
   cout<<"Balance : $"<<act.getCurrentBalance()<<endl;

   system("pause");
   return 0;
}

Sample Output:

Account Name :John Smith
Balance : $100

Add a comment
Know the answer?
Add Answer to:
Either know this is just a homework assignment please if you dont know the answer or...
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
  • Please show it in C++. Thank you! Problem Definition Create an inheritance hierarchy containing base class...

    Please show it in C++. Thank you! Problem Definition Create an inheritance hierarchy containing base class Account and derived class Savings-Account. Base class Account should include one data member of type double to represent the account balance. The class should provide a constructor that receives an initial baiance and uses it to initialize the data member. The class should provide three member functions. Member function credit should add an amount to the current balance. Member function debit should withdraw money...

  • C++ edit: You start with the code given and then modify it so that it does...

    C++ edit: You start with the code given and then modify it so that it does what the following asks for. Create an EmployeeException class whose constructor receives a String that consists of an employee’s ID and pay rate. Modify the Employee class so that it has two more fields, idNum and hourlyWage. The Employee constructor requires values for both fields. Upon construction, throw an EmployeeException if the hourlyWage is less than $6.00 or over $50.00. Write a program that...

  • C++ please 27. How do you differentiate a destructor from the rest? 28. Can a static...

    C++ please 27. How do you differentiate a destructor from the rest? 28. Can a static function call an instance one? 29. Can an instance function call a static one? 30. How many objects are created? class Account { public: string firstName; string lastName; double balance; Account* p; 31. Discuss the differences among the following access modifiers, public, private, and protected. 32. When do you use the following notation? . (dot notation) :: (scope resolution operator) -> (arrow notation) 33....

  • Please implement the following problem in basic C++ code and include detailed comments so that I...

    Please implement the following problem in basic C++ code and include detailed comments so that I am able to understand the processes for the solution. Thanks in advance. // personType.h #include <string> using namespace std; class personType { public: virtual void print() const; void setName(string first, string last); string getFirstName() const; string getLastName() const; personType(string first = "", string last = ""); protected: string firstName; string lastName; }; // personTypeImp.cpp #include <iostream> #include <string> #include "personType.h" using namespace std; void...

  • this is the question, please help me with this python coding question thanks and appreciate your...

    this is the question, please help me with this python coding question thanks and appreciate your help 1. Create an object call Accounts. This is to be used in a banking system. 2. Initialize the account with three data as inputs : Firstname, Lastname and balance. 3. Create 4 additional member functions: Deposit, Withdraw, Fee Calculations, interest The fee calculation is going to be $10 per month if the total amount in the account is less than $1000. Interest is...

  • Assignment: Chapter 18 introduces you to linked lists. In this homework assignment you will use the...

    Assignment: Chapter 18 introduces you to linked lists. In this homework assignment you will use the algorithms presented in this chapter to implement a list of names that should be kept in alphabetical order. Section 18.2 defines the Linked List Operations based on a list of numbers. You will change this code to work with a list of names. struct ListNode { string firstNname; string lastName; struct ListNode *next; }; Rename class NumberList to something more appropriate like StringList or...

  • For this lab assignment, you will be writing a few classes that can be used by...

    For this lab assignment, you will be writing a few classes that can be used by an educator to grade multiple choice exams. It will give you experience using some Standard Java Classes (Strings, Lists, Maps), which you will need for future projects. The following are the required classes: Student – a Student object has three private instance variables: lastName, a String; firstName, a String; and average, a double. It has accessor methods for lastName and firstName, and an accessor...

  • using C++ language!! please help me out with this homework In this exercise, you will have...

    using C++ language!! please help me out with this homework In this exercise, you will have to create from scratch and utilize a class called Student1430. Student 1430 has 4 private member attributes: lastName (string) firstName (string) exams (an integer array of fixed size of 4) average (double) Student1430 also has the following member functions: 1. A default constructor, which sets firstName and lastName to empty strings, and all exams and average to 0. 2. A constructor with 3 parameters:...

  • Purpose: Demonstrate the ability to create and manipulate classes, data members, and member functions. This assignment...

    Purpose: Demonstrate the ability to create and manipulate classes, data members, and member functions. This assignment also aims at creating a C++ project to handle multiple files (one header file and two .cpp files) at the same time. Remember to follow documentation and variable name guidelines. Create a C++ project to implement a simplified banking system. Your bank is small, so it can have a maximum of 100 accounts. Use an array of pointers to objects for this. However, your...

  • Please hlep as I've tried this C++ program and keep coming up with the wrong syntax...

    Please hlep as I've tried this C++ program and keep coming up with the wrong syntax somewhere. I need help defining 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 functions to manipulate an object. Use a static member in...

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