SlideShare a Scribd company logo
1 of 2
Download to read offline
BLG332E
Object Oriented Programming
Practice Session 3
Exercise 4
In this exercise, you create a simple version of the Account class. A test program,
TestBanking.cpp, has been written that creates a single account.
Task 1: Change your working directory to chap03/exercise4
Task 2: Create a class Account that implements the UML diagram given above.
a) Declare one private attribute: balance; tis attribute holds the current (or “running”) balance of
the bank account.
b) Declare a public constructor that takes one parameter (init_balance) that populates the
balance attribute.
c) Declare a public method getBalance that retrieves the current balance.
d) Declare a public method deposit that adds the amount parameter to the current balance.
e) Declare a public method withdraw that removes the amount parameter from the current
balance.
Task 3: Read the TestBanking.cpp code.
Task 4: Compile Account.cpp and TestBanking.cpp.
Task 5: Run the program. You should see the following output:
Create an account with 500.0 balance
Withdraw 150.0
Deposit 22.50
Withdraw 47.62
The account has a balance of 324.88
Exercise 5
In this exercise you will expand the Banking project by adding a Customer class. A customer will
contain one Account object.
Task 1: Change your working directory to chap03/exercise5
Task 2: Copy Account class from the previous exercise lab
cp ../exercise4/Account.* .
Task 2: Create a class Customer class that implements the above UML diagram
a) Declare three private attributes: firstName, lastName, and account.
b) Declare a public constructor that takes two parameters (f and l) that populate the object
attributes.
c) Declare two public accessors for the object attributes; the methods getFirstName and
getlastName return the appropriate attribute.
d) Declare a public method setAccount to assign the account attribute.
e) Declare a public method getAccount to retrieve the account attribute.
f)
Task 3: Read the TestBanking.cpp code.
Task 4: Compile Account.cpp, Customer.cpp, and TestBanking.cpp.
Task 5: Run the program. The output generated should be:
Creating the Customer Jane Smith
Creating her account with a 500.0 balance.
Withdraw 150.0
Deposit 22.50
Withdraw 47.62
Customer [Smith, Jane] has a balance of 324.88
Exercise 6
In this exercise, you will modify the withdraw method to return a boolean value to specify whether the
transaction was successful.
Task 1: Change your working directory to chap03/exercise6
Task 2: You can copy the Account.* and Customer.* files you created in Exercise 5.
Task 3: Modify the Account class to place conditions on the withdraw and deposit methods.
a) Modify the deposit method to return true.
b) Modify the withdraw method to check that the amount being withdrawn is not greater
than the current balance. If amt is less than balance, then subtract the amount from the
balance and return true; else leave the balance alone and return false.
Task 4: Read the TestBanking.cpp code.
Task 5: Compile Account.cpp, Customer.cpp, and TestBanking.cpp.
Task 6: Run the program. The output generated should be:
Creating the Customer Jane Smith
Creating her account with a 500.0 balance.
Withdraw 150.0:true
Deposit 22.50: true
Withdraw 47.62: false
Withdraw 400.0: false
Customer [Smith, Jane] has a balance of 324.88

More Related Content

Viewers also liked

Viewers also liked (6)

Ponters
PontersPonters
Ponters
 
C++ questions and answers
C++ questions and answersC++ questions and answers
C++ questions and answers
 
07 Input Output
07  Input  Output07  Input  Output
07 Input Output
 
Pointers
PointersPointers
Pointers
 
08 c++ Operator Overloading.ppt
08 c++ Operator Overloading.ppt08 c++ Operator Overloading.ppt
08 c++ Operator Overloading.ppt
 
Unit 6 pointers
Unit 6   pointersUnit 6   pointers
Unit 6 pointers
 

Similar to Lo48

Comp 220 ilab 3 of 7
Comp 220 ilab 3 of 7Comp 220 ilab 3 of 7
Comp 220 ilab 3 of 7ashhadiqbal
 
Comp 220 ilab 3 of 7
Comp 220 ilab 3 of 7Comp 220 ilab 3 of 7
Comp 220 ilab 3 of 7solutionjug4
 
CIS 247C iLab 4 of 7: Composition and Class Interfaces
CIS 247C iLab 4 of 7: Composition and Class Interfaces  CIS 247C iLab 4 of 7: Composition and Class Interfaces
CIS 247C iLab 4 of 7: Composition and Class Interfaces HomeWork-Fox
 
Cis247 a ilab 4 composition and class interfaces
Cis247 a ilab 4 composition and class interfacesCis247 a ilab 4 composition and class interfaces
Cis247 a ilab 4 composition and class interfacesccis224477
 
Cis247 a ilab 4 composition and class interfaces
Cis247 a ilab 4 composition and class interfacesCis247 a ilab 4 composition and class interfaces
Cis247 a ilab 4 composition and class interfacesccis224477
 
Cis247 i lab 4 composition and class interfaces
Cis247 i lab 4 composition and class interfacesCis247 i lab 4 composition and class interfaces
Cis247 i lab 4 composition and class interfacessdjdskjd9097
 
Cis247 a ilab 4 composition and class interfaces
Cis247 a ilab 4 composition and class interfacesCis247 a ilab 4 composition and class interfaces
Cis247 a ilab 4 composition and class interfacescis247
 
Assignment Instructions 2_7aExplain the interrelationships bet.docx
Assignment Instructions 2_7aExplain the interrelationships bet.docxAssignment Instructions 2_7aExplain the interrelationships bet.docx
Assignment Instructions 2_7aExplain the interrelationships bet.docxssuser562afc1
 
Please distinguish between the .h and .cpp file, create a fully work.pdf
Please distinguish between the .h and .cpp file, create a fully work.pdfPlease distinguish between the .h and .cpp file, create a fully work.pdf
Please distinguish between the .h and .cpp file, create a fully work.pdfneerajsachdeva33
 
Account.h Definition of Account class. #ifndef ACCOUNT_H #d.pdf
Account.h  Definition of Account class. #ifndef ACCOUNT_H #d.pdfAccount.h  Definition of Account class. #ifndef ACCOUNT_H #d.pdf
Account.h Definition of Account class. #ifndef ACCOUNT_H #d.pdfanujmkt
 
1-What are the opportunities and threats that could impact the org
1-What are the opportunities and threats that could impact the org1-What are the opportunities and threats that could impact the org
1-What are the opportunities and threats that could impact the orgAbbyWhyte974
 
1-What are the opportunities and threats that could impact the org
1-What are the opportunities and threats that could impact the org1-What are the opportunities and threats that could impact the org
1-What are the opportunities and threats that could impact the orgMartineMccracken314
 
Lab 2: Importing requirements artifacts from a CSV file
Lab 2: Importing requirements artifacts from a CSV file Lab 2: Importing requirements artifacts from a CSV file
Lab 2: Importing requirements artifacts from a CSV file IBM Rational software
 
Comp 220 i lab 3 bank account lab report and source code
Comp 220 i lab 3 bank account lab report and source codeComp 220 i lab 3 bank account lab report and source code
Comp 220 i lab 3 bank account lab report and source codepradesigali1
 
Cis247 i lab 5 inheritance
Cis247 i lab 5 inheritanceCis247 i lab 5 inheritance
Cis247 i lab 5 inheritancesdjdskjd9097
 
Java: Class Design Examples
Java: Class Design ExamplesJava: Class Design Examples
Java: Class Design ExamplesTareq Hasan
 
Cis247 a ilab 5 inheritance
Cis247 a ilab 5 inheritanceCis247 a ilab 5 inheritance
Cis247 a ilab 5 inheritanceccis224477
 

Similar to Lo48 (20)

Comp 220 ilab 3 of 7
Comp 220 ilab 3 of 7Comp 220 ilab 3 of 7
Comp 220 ilab 3 of 7
 
Comp 220 ilab 3 of 7
Comp 220 ilab 3 of 7Comp 220 ilab 3 of 7
Comp 220 ilab 3 of 7
 
CIS 247C iLab 4 of 7: Composition and Class Interfaces
CIS 247C iLab 4 of 7: Composition and Class Interfaces  CIS 247C iLab 4 of 7: Composition and Class Interfaces
CIS 247C iLab 4 of 7: Composition and Class Interfaces
 
Comp 220 lab 3
Comp 220 lab 3Comp 220 lab 3
Comp 220 lab 3
 
T4
T4T4
T4
 
Cis247 a ilab 4 composition and class interfaces
Cis247 a ilab 4 composition and class interfacesCis247 a ilab 4 composition and class interfaces
Cis247 a ilab 4 composition and class interfaces
 
Cis247 a ilab 4 composition and class interfaces
Cis247 a ilab 4 composition and class interfacesCis247 a ilab 4 composition and class interfaces
Cis247 a ilab 4 composition and class interfaces
 
Cis247 i lab 4 composition and class interfaces
Cis247 i lab 4 composition and class interfacesCis247 i lab 4 composition and class interfaces
Cis247 i lab 4 composition and class interfaces
 
Cis247 a ilab 4 composition and class interfaces
Cis247 a ilab 4 composition and class interfacesCis247 a ilab 4 composition and class interfaces
Cis247 a ilab 4 composition and class interfaces
 
Assignment Instructions 2_7aExplain the interrelationships bet.docx
Assignment Instructions 2_7aExplain the interrelationships bet.docxAssignment Instructions 2_7aExplain the interrelationships bet.docx
Assignment Instructions 2_7aExplain the interrelationships bet.docx
 
Please distinguish between the .h and .cpp file, create a fully work.pdf
Please distinguish between the .h and .cpp file, create a fully work.pdfPlease distinguish between the .h and .cpp file, create a fully work.pdf
Please distinguish between the .h and .cpp file, create a fully work.pdf
 
Account.h Definition of Account class. #ifndef ACCOUNT_H #d.pdf
Account.h  Definition of Account class. #ifndef ACCOUNT_H #d.pdfAccount.h  Definition of Account class. #ifndef ACCOUNT_H #d.pdf
Account.h Definition of Account class. #ifndef ACCOUNT_H #d.pdf
 
1-What are the opportunities and threats that could impact the org
1-What are the opportunities and threats that could impact the org1-What are the opportunities and threats that could impact the org
1-What are the opportunities and threats that could impact the org
 
1-What are the opportunities and threats that could impact the org
1-What are the opportunities and threats that could impact the org1-What are the opportunities and threats that could impact the org
1-What are the opportunities and threats that could impact the org
 
Lab 2: Importing requirements artifacts from a CSV file
Lab 2: Importing requirements artifacts from a CSV file Lab 2: Importing requirements artifacts from a CSV file
Lab 2: Importing requirements artifacts from a CSV file
 
Comp 220 i lab 3 bank account lab report and source code
Comp 220 i lab 3 bank account lab report and source codeComp 220 i lab 3 bank account lab report and source code
Comp 220 i lab 3 bank account lab report and source code
 
Cis247 i lab 5 inheritance
Cis247 i lab 5 inheritanceCis247 i lab 5 inheritance
Cis247 i lab 5 inheritance
 
11 job costing
11 job costing11 job costing
11 job costing
 
Java: Class Design Examples
Java: Class Design ExamplesJava: Class Design Examples
Java: Class Design Examples
 
Cis247 a ilab 5 inheritance
Cis247 a ilab 5 inheritanceCis247 a ilab 5 inheritance
Cis247 a ilab 5 inheritance
 

More from lksoo

More from lksoo (20)

Lo43
Lo43Lo43
Lo43
 
Lo39
Lo39Lo39
Lo39
 
Lo37
Lo37Lo37
Lo37
 
Lo27
Lo27Lo27
Lo27
 
Lo17
Lo17Lo17
Lo17
 
Lo12
Lo12Lo12
Lo12
 
T3
T3T3
T3
 
T2
T2T2
T2
 
T1
T1T1
T1
 
P5
P5P5
P5
 
P4
P4P4
P4
 
P3
P3P3
P3
 
P1
P1P1
P1
 
P2
P2P2
P2
 
L10
L10L10
L10
 
L9
L9L9
L9
 
L8
L8L8
L8
 
L7
L7L7
L7
 
L6
L6L6
L6
 
L5
L5L5
L5
 

Recently uploaded

Akola Call Girls #9907093804 Contact Number Escorts Service Akola
Akola Call Girls #9907093804 Contact Number Escorts Service AkolaAkola Call Girls #9907093804 Contact Number Escorts Service Akola
Akola Call Girls #9907093804 Contact Number Escorts Service Akolasrsj9000
 
Low Rate Call Girls in Laxmi Nagar Delhi Call 9990771857
Low Rate Call Girls in Laxmi Nagar Delhi Call 9990771857Low Rate Call Girls in Laxmi Nagar Delhi Call 9990771857
Low Rate Call Girls in Laxmi Nagar Delhi Call 9990771857delhimodel235
 
Zagor VČ OP 055 - Oluja nad Haitijem.pdf
Zagor VČ OP 055 - Oluja nad Haitijem.pdfZagor VČ OP 055 - Oluja nad Haitijem.pdf
Zagor VČ OP 055 - Oluja nad Haitijem.pdfStripovizijacom
 
Call Girl Service in Karachi +923081633338 Karachi Call Girls
Call Girl Service in Karachi +923081633338 Karachi Call GirlsCall Girl Service in Karachi +923081633338 Karachi Call Girls
Call Girl Service in Karachi +923081633338 Karachi Call GirlsAyesha Khan
 
How Can You Get Dubai Call Girls +971564860409 Call Girls Dubai?
How Can You Get Dubai Call Girls +971564860409 Call Girls Dubai?How Can You Get Dubai Call Girls +971564860409 Call Girls Dubai?
How Can You Get Dubai Call Girls +971564860409 Call Girls Dubai?kexey39068
 
FULL ENJOY - 9953040155 Call Girls in Gtb Nagar | Delhi
FULL ENJOY - 9953040155 Call Girls in Gtb Nagar | DelhiFULL ENJOY - 9953040155 Call Girls in Gtb Nagar | Delhi
FULL ENJOY - 9953040155 Call Girls in Gtb Nagar | DelhiMalviyaNagarCallGirl
 
Strip Zagor Extra 322 - Dva ortaka.pdf
Strip   Zagor Extra 322 - Dva ortaka.pdfStrip   Zagor Extra 322 - Dva ortaka.pdf
Strip Zagor Extra 322 - Dva ortaka.pdfStripovizijacom
 
FULL ENJOY - 9953040155 Call Girls in Laxmi Nagar | Delhi
FULL ENJOY - 9953040155 Call Girls in Laxmi Nagar | DelhiFULL ENJOY - 9953040155 Call Girls in Laxmi Nagar | Delhi
FULL ENJOY - 9953040155 Call Girls in Laxmi Nagar | DelhiMalviyaNagarCallGirl
 
Bridge Fight Board by Daniel Johnson dtjohnsonart.com
Bridge Fight Board by Daniel Johnson dtjohnsonart.comBridge Fight Board by Daniel Johnson dtjohnsonart.com
Bridge Fight Board by Daniel Johnson dtjohnsonart.comthephillipta
 
Olivia Cox. intertextual references.pptx
Olivia Cox. intertextual references.pptxOlivia Cox. intertextual references.pptx
Olivia Cox. intertextual references.pptxLauraFagan6
 
Alex and Chloe by Daniel Johnson Storyboard
Alex and Chloe by Daniel Johnson StoryboardAlex and Chloe by Daniel Johnson Storyboard
Alex and Chloe by Daniel Johnson Storyboardthephillipta
 
FULL ENJOY - 9953040155 Call Girls in Paschim Vihar | Delhi
FULL ENJOY - 9953040155 Call Girls in Paschim Vihar | DelhiFULL ENJOY - 9953040155 Call Girls in Paschim Vihar | Delhi
FULL ENJOY - 9953040155 Call Girls in Paschim Vihar | DelhiMalviyaNagarCallGirl
 
Mandi House Call Girls : ☎ 8527673949, Low rate Call Girls
Mandi House Call Girls : ☎ 8527673949, Low rate Call GirlsMandi House Call Girls : ☎ 8527673949, Low rate Call Girls
Mandi House Call Girls : ☎ 8527673949, Low rate Call Girlsashishs7044
 
Jagat Puri Call Girls : ☎ 8527673949, Low rate Call Girls
Jagat Puri Call Girls : ☎ 8527673949, Low rate Call GirlsJagat Puri Call Girls : ☎ 8527673949, Low rate Call Girls
Jagat Puri Call Girls : ☎ 8527673949, Low rate Call Girlsashishs7044
 
SHIVNA SAHITYIKI APRIL JUNE 2024 Magazine
SHIVNA SAHITYIKI APRIL JUNE 2024 MagazineSHIVNA SAHITYIKI APRIL JUNE 2024 Magazine
SHIVNA SAHITYIKI APRIL JUNE 2024 MagazineShivna Prakashan
 
9654467111 Full Enjoy @24/7 Call Girls In Saket Delhi Ncr
9654467111 Full Enjoy @24/7 Call Girls In Saket Delhi Ncr9654467111 Full Enjoy @24/7 Call Girls In Saket Delhi Ncr
9654467111 Full Enjoy @24/7 Call Girls In Saket Delhi NcrSapana Sha
 
Roadrunner Lodge, Motel/Residence, Tucumcari NM
Roadrunner Lodge, Motel/Residence, Tucumcari NMRoadrunner Lodge, Motel/Residence, Tucumcari NM
Roadrunner Lodge, Motel/Residence, Tucumcari NMroute66connected
 
Delhi Room Call Girls : ☎ 8527673949, Low rate Call girl service
Delhi Room Call Girls : ☎ 8527673949, Low rate Call girl serviceDelhi Room Call Girls : ☎ 8527673949, Low rate Call girl service
Delhi Room Call Girls : ☎ 8527673949, Low rate Call girl serviceashishs7044
 
FULL ENJOY - 9953040155 Call Girls in Dwarka Mor | Delhi
FULL ENJOY - 9953040155 Call Girls in Dwarka Mor | DelhiFULL ENJOY - 9953040155 Call Girls in Dwarka Mor | Delhi
FULL ENJOY - 9953040155 Call Girls in Dwarka Mor | DelhiMalviyaNagarCallGirl
 

Recently uploaded (20)

Akola Call Girls #9907093804 Contact Number Escorts Service Akola
Akola Call Girls #9907093804 Contact Number Escorts Service AkolaAkola Call Girls #9907093804 Contact Number Escorts Service Akola
Akola Call Girls #9907093804 Contact Number Escorts Service Akola
 
Low Rate Call Girls in Laxmi Nagar Delhi Call 9990771857
Low Rate Call Girls in Laxmi Nagar Delhi Call 9990771857Low Rate Call Girls in Laxmi Nagar Delhi Call 9990771857
Low Rate Call Girls in Laxmi Nagar Delhi Call 9990771857
 
Zagor VČ OP 055 - Oluja nad Haitijem.pdf
Zagor VČ OP 055 - Oluja nad Haitijem.pdfZagor VČ OP 055 - Oluja nad Haitijem.pdf
Zagor VČ OP 055 - Oluja nad Haitijem.pdf
 
Call Girl Service in Karachi +923081633338 Karachi Call Girls
Call Girl Service in Karachi +923081633338 Karachi Call GirlsCall Girl Service in Karachi +923081633338 Karachi Call Girls
Call Girl Service in Karachi +923081633338 Karachi Call Girls
 
How Can You Get Dubai Call Girls +971564860409 Call Girls Dubai?
How Can You Get Dubai Call Girls +971564860409 Call Girls Dubai?How Can You Get Dubai Call Girls +971564860409 Call Girls Dubai?
How Can You Get Dubai Call Girls +971564860409 Call Girls Dubai?
 
FULL ENJOY - 9953040155 Call Girls in Gtb Nagar | Delhi
FULL ENJOY - 9953040155 Call Girls in Gtb Nagar | DelhiFULL ENJOY - 9953040155 Call Girls in Gtb Nagar | Delhi
FULL ENJOY - 9953040155 Call Girls in Gtb Nagar | Delhi
 
Strip Zagor Extra 322 - Dva ortaka.pdf
Strip   Zagor Extra 322 - Dva ortaka.pdfStrip   Zagor Extra 322 - Dva ortaka.pdf
Strip Zagor Extra 322 - Dva ortaka.pdf
 
FULL ENJOY - 9953040155 Call Girls in Laxmi Nagar | Delhi
FULL ENJOY - 9953040155 Call Girls in Laxmi Nagar | DelhiFULL ENJOY - 9953040155 Call Girls in Laxmi Nagar | Delhi
FULL ENJOY - 9953040155 Call Girls in Laxmi Nagar | Delhi
 
Bridge Fight Board by Daniel Johnson dtjohnsonart.com
Bridge Fight Board by Daniel Johnson dtjohnsonart.comBridge Fight Board by Daniel Johnson dtjohnsonart.com
Bridge Fight Board by Daniel Johnson dtjohnsonart.com
 
Olivia Cox. intertextual references.pptx
Olivia Cox. intertextual references.pptxOlivia Cox. intertextual references.pptx
Olivia Cox. intertextual references.pptx
 
Alex and Chloe by Daniel Johnson Storyboard
Alex and Chloe by Daniel Johnson StoryboardAlex and Chloe by Daniel Johnson Storyboard
Alex and Chloe by Daniel Johnson Storyboard
 
FULL ENJOY - 9953040155 Call Girls in Paschim Vihar | Delhi
FULL ENJOY - 9953040155 Call Girls in Paschim Vihar | DelhiFULL ENJOY - 9953040155 Call Girls in Paschim Vihar | Delhi
FULL ENJOY - 9953040155 Call Girls in Paschim Vihar | Delhi
 
Bur Dubai Call Girls # 971504361175 # Call Girls In Bur Dubai || (UAE)
Bur Dubai Call Girls # 971504361175 # Call Girls In Bur Dubai || (UAE)Bur Dubai Call Girls # 971504361175 # Call Girls In Bur Dubai || (UAE)
Bur Dubai Call Girls # 971504361175 # Call Girls In Bur Dubai || (UAE)
 
Mandi House Call Girls : ☎ 8527673949, Low rate Call Girls
Mandi House Call Girls : ☎ 8527673949, Low rate Call GirlsMandi House Call Girls : ☎ 8527673949, Low rate Call Girls
Mandi House Call Girls : ☎ 8527673949, Low rate Call Girls
 
Jagat Puri Call Girls : ☎ 8527673949, Low rate Call Girls
Jagat Puri Call Girls : ☎ 8527673949, Low rate Call GirlsJagat Puri Call Girls : ☎ 8527673949, Low rate Call Girls
Jagat Puri Call Girls : ☎ 8527673949, Low rate Call Girls
 
SHIVNA SAHITYIKI APRIL JUNE 2024 Magazine
SHIVNA SAHITYIKI APRIL JUNE 2024 MagazineSHIVNA SAHITYIKI APRIL JUNE 2024 Magazine
SHIVNA SAHITYIKI APRIL JUNE 2024 Magazine
 
9654467111 Full Enjoy @24/7 Call Girls In Saket Delhi Ncr
9654467111 Full Enjoy @24/7 Call Girls In Saket Delhi Ncr9654467111 Full Enjoy @24/7 Call Girls In Saket Delhi Ncr
9654467111 Full Enjoy @24/7 Call Girls In Saket Delhi Ncr
 
Roadrunner Lodge, Motel/Residence, Tucumcari NM
Roadrunner Lodge, Motel/Residence, Tucumcari NMRoadrunner Lodge, Motel/Residence, Tucumcari NM
Roadrunner Lodge, Motel/Residence, Tucumcari NM
 
Delhi Room Call Girls : ☎ 8527673949, Low rate Call girl service
Delhi Room Call Girls : ☎ 8527673949, Low rate Call girl serviceDelhi Room Call Girls : ☎ 8527673949, Low rate Call girl service
Delhi Room Call Girls : ☎ 8527673949, Low rate Call girl service
 
FULL ENJOY - 9953040155 Call Girls in Dwarka Mor | Delhi
FULL ENJOY - 9953040155 Call Girls in Dwarka Mor | DelhiFULL ENJOY - 9953040155 Call Girls in Dwarka Mor | Delhi
FULL ENJOY - 9953040155 Call Girls in Dwarka Mor | Delhi
 

Lo48

  • 1. BLG332E Object Oriented Programming Practice Session 3 Exercise 4 In this exercise, you create a simple version of the Account class. A test program, TestBanking.cpp, has been written that creates a single account. Task 1: Change your working directory to chap03/exercise4 Task 2: Create a class Account that implements the UML diagram given above. a) Declare one private attribute: balance; tis attribute holds the current (or “running”) balance of the bank account. b) Declare a public constructor that takes one parameter (init_balance) that populates the balance attribute. c) Declare a public method getBalance that retrieves the current balance. d) Declare a public method deposit that adds the amount parameter to the current balance. e) Declare a public method withdraw that removes the amount parameter from the current balance. Task 3: Read the TestBanking.cpp code. Task 4: Compile Account.cpp and TestBanking.cpp. Task 5: Run the program. You should see the following output: Create an account with 500.0 balance Withdraw 150.0 Deposit 22.50 Withdraw 47.62 The account has a balance of 324.88 Exercise 5 In this exercise you will expand the Banking project by adding a Customer class. A customer will contain one Account object. Task 1: Change your working directory to chap03/exercise5 Task 2: Copy Account class from the previous exercise lab cp ../exercise4/Account.* .
  • 2. Task 2: Create a class Customer class that implements the above UML diagram a) Declare three private attributes: firstName, lastName, and account. b) Declare a public constructor that takes two parameters (f and l) that populate the object attributes. c) Declare two public accessors for the object attributes; the methods getFirstName and getlastName return the appropriate attribute. d) Declare a public method setAccount to assign the account attribute. e) Declare a public method getAccount to retrieve the account attribute. f) Task 3: Read the TestBanking.cpp code. Task 4: Compile Account.cpp, Customer.cpp, and TestBanking.cpp. Task 5: Run the program. The output generated should be: Creating the Customer Jane Smith Creating her account with a 500.0 balance. Withdraw 150.0 Deposit 22.50 Withdraw 47.62 Customer [Smith, Jane] has a balance of 324.88 Exercise 6 In this exercise, you will modify the withdraw method to return a boolean value to specify whether the transaction was successful. Task 1: Change your working directory to chap03/exercise6 Task 2: You can copy the Account.* and Customer.* files you created in Exercise 5. Task 3: Modify the Account class to place conditions on the withdraw and deposit methods. a) Modify the deposit method to return true. b) Modify the withdraw method to check that the amount being withdrawn is not greater than the current balance. If amt is less than balance, then subtract the amount from the balance and return true; else leave the balance alone and return false. Task 4: Read the TestBanking.cpp code. Task 5: Compile Account.cpp, Customer.cpp, and TestBanking.cpp. Task 6: Run the program. The output generated should be: Creating the Customer Jane Smith Creating her account with a 500.0 balance. Withdraw 150.0:true Deposit 22.50: true Withdraw 47.62: false Withdraw 400.0: false Customer [Smith, Jane] has a balance of 324.88