java contrsuctor 1)Your parents have given you a credit card!!!! Both of your pa
ID: 3927751 • Letter: J
Question
java contrsuctor 1)Your parents have given you a credit card!!!! Both of your parents and yourself (+ any siblings) all have your own individual cards tied to the same account. This means that all charges collectively go to the same account. Define a class named CreditCardAcct that has the following instance variables: -Card hold name -Card # -Purchases (made by this card holder) Create a constructor that allows a user of the class to initialize all values. Create the following static variables: -Overall account limit, setting limit to $10,000.00 (can't change) -Overall account balance Create a Purchase method 2) Create a driver program with atleast 10 different purchases to demo the class methods
please include comments for thumbs up!
if you include a plan/design simpler than the ones in the Starting Out with Java book solutions would be best
Explanation / Answer
Please find the required program along with its output. Please see the comments against each line to understand the step.
---------------------------------------------------------------------------------------
OUTPUT:
Parent : Trying purchase of 628.7370813579835
Purchase done!
Credit limit left: 9371.262918642016
Child : Trying purchase of 78.96941820226178
Purchase done!
Credit limit left: 9292.293500439755
Parent : Trying purchase of 396.2275856885705
Purchase done!
Credit limit left: 8896.065914751185
Child : Trying purchase of 494.29184494178935
Purchase done!
Credit limit left: 8401.774069809395
Parent : Trying purchase of 876.8738438811326
Purchase done!
Credit limit left: 7524.900225928262
Child : Trying purchase of 442.08433504359976
Purchase done!
Credit limit left: 7082.815890884663
Parent : Trying purchase of 801.0835556273652
Purchase done!
Credit limit left: 6281.732335257298
Child : Trying purchase of 589.9428940663042
Purchase done!
Credit limit left: 5691.789441190993
Parent : Trying purchase of 601.5136014699661
Purchase done!
Credit limit left: 5090.275839721026
Child : Trying purchase of 706.2954260502509
Purchase done!
Credit limit left: 4383.980413670775
Parent : Trying purchase of 580.4446143615511
Purchase done!
Credit limit left: 3803.5357993092243
Child : Trying purchase of 78.99647671451004
Purchase done!
Credit limit left: 3724.539322594714
Parent : Trying purchase of 814.4354399743762
Purchase done!
Credit limit left: 2910.103882620338
Child : Trying purchase of 128.30606174145342
Purchase done!
Credit limit left: 2781.7978208788845
Parent : Trying purchase of 186.388551590392
Purchase done!
Credit limit left: 2595.4092692884924
Child : Trying purchase of 413.9943198520032
Purchase done!
Credit limit left: 2181.414949436489
Parent : Trying purchase of 356.39563071040027
Purchase done!
Credit limit left: 1825.0193187260888
Child : Trying purchase of 835.438292805371
Purchase done!
Credit limit left: 989.5810259207178
Parent : Trying purchase of 150.6136949282414
Purchase done!
Credit limit left: 838.9673309924765
Child : Trying purchase of 726.4743431495301
Purchase done!
Credit limit left: 112.49298784294638
Parent : Trying purchase of 67.6097691498685
Purchase done!
Credit limit left: 44.88321869307788
Child : Trying purchase of 348.16505506378525
Insufficient amount! purchase not done
Related Questions
Navigate
Integrity-first tutoring: explanations and feedback only — we do not complete graded work. Learn more.