Rewrite the Account class to store the balance as a BigDecimal object and to perform all calculations
Question:
Rewrite the Account class to store the balance as a BigDecimal object and to perform all calculations using BigDecimals.
Account class
Transcribed Image Text:
2 3 4 5 6 7 // Fig. 7.8: Account.java // Account class with a double instance variable balance and a constructor // and deposit method that perform validation. public class Account { private String name; // instance variable private double balance; // instance variable // Account constructor that receives two parameters public Account (String name, double balance) { 8 9 10 11 12 13 14 15 16 17 18 } this.name = name; // assign name to instance variable name // validate that the balance is greater than 0.0; if it's not, // instance variable balance keeps its default initial value of 0.0 if (balance >0.0) { // if the balance is valid } this.balance = balance; // assign it to instance variable balance 19 // method that deposits (adds) only a valid amount to the balance public void deposit (double depositAmount) { 20 21 22 23 24 25 } if (depositAmount > 0.0) { // if the depositAmount is valid balance += depositAmount; // add it to the balance } 26 // method returns the account balance public double getBalance() { 27 28 29 30 } 31 32 33 34 35 36 return balance; // method that sets the name public void setName(String name) { this.name name; } // method that returns the name public String getName() { 37 38 39 40 } 41 } return name;
Fantastic news! We've Found the answer you've been seeking!
Step by Step Answer:
Answer rating: 100% (QA)
Answered By
Sagar Kumawat
I am Sagar kumawat currently pursuing MA economics from Central University Of Rajashtan, I have completed my Under graduation in Economics Honours and secured 71%. Have keen interest in Research and policy making, currently working on one research topic of " universal basic income in India". In my spare time I spend my time in my hobbies like playing keyboard, dancing, Handball. Data science and economics enthusiast, have done various coursers to build more knowledge in these field. I have hand on experience on econometrics tools like Eviews, SPSS, MS excel. I am well versed in English speaking, communication and leadership qualities . Participate in lots of public speaking competitions like debates, extempore, poetry reciting and was winner of inter-level.
I once was a economics tutor to one the prestigious coaching institute, where i teach the CA (chartered accountant) students. The course was comprehensive one, it provide overall knowledge of economics to them.
0.00
0 Reviews
10+ Question Solved
Related Book For
Java How To Program Late Objects Version
ISBN: 9780136123712
8th Edition
Authors: Paul Deitel, Deitel & Associates
Question Posted:
Students also viewed these Computer science questions
-
The information provided in this test allows you to set up all ledgers for an Ontario company named DERMAL DECOR. Dermal Decor specializes in high quality aesthetic body art with sterile equipment....
-
all should run as the output shown in attachment without any errors Modify homework2 to include additional functionalities: Modify the existing program. 1. Bank account client a. When creating an...
-
answer the question clearly You are building a flight-control system for which a convincing safety case must be made. Would you assign the tasks of safety requirements engineering, test case...
-
Write a film script using this title "The arrival". THE ARRIVAL' WRITE A FILM SCRIPT USING THIS, TITLE DUMBFOUND: ASTONISH, AMAZE E62-67 SIMILE A METAPHOR ALLITERATION LIST OF THREE A LINE FROM A...
-
A summary of the assets and equities of Pot Corporation and its 80 percent-owned subsidiary, Sea Corporation, at December 31, 2016, is given as follows (in thousands): On January 2, 2017, Sea...
-
Consider a resource-allocation problem having the following data. Contribution per unit = profit per unit of the activity. a. Formulate a linear programming model for this problem on a spreadsheet....
-
The manager of Gladstone Ltd is not convinced of the scientific evidence behind climate change, and does not consider it necessary to adopt changes in the companys operations which would decrease its...
-
City Place Movie Theaters has four employees and pays them on an hourly basis. During the week beginning June 24 and ending June 30, 2016, these employees worked the hours shown below. Information...
-
The Reading Warehouse distributes hardback books to retail stores and extends credit terms of 2/7, n/30 to all of its customers. During the month of June the following inventory transactions...
-
Use inheritance to create an exception superclass (called ExceptionA) and exception subclasses ExceptionB and ExceptionC, where ExceptionB inherits from ExceptionA and ExceptionC inherits from...
-
Modify the DrawStars example so that all the stars have Rotate transition animations that execute indefinitelythat is, set each animations cycle count to Animation.INDEFINITE. DrawStars example //...
-
When a balance sheet reports a substantial dollar amount for goodwill, discuss what we should be concerned with in our analysis.
-
Although many journals subscribe to the guidelines of the International Committee of Medical Journal Editors, many do not, and many researchers do not follow the practices that it recommends. What...
-
In your opinion, between the expansionary monetary policy and the contractionary monetary policy, which is more effective, and why?
-
for ulta Did the company accomplish the goal of liquidity as of the end of the most recent year? How do you know this? (Be sure to indicate which financial statement shows this information.)
-
What is a fitness log? a publication describing which diets are the healthiest information given to someone else about his or her performance a document used to record the type and amount of workouts...
-
1. Completed Academic Integrity Module (AIM) Please note: Non-completion of this element will result in a withheld grade for this task until it is completed, 2. A CV/resume, 3. Completed skills...
-
A childs pogo stick (Fig P8.56) stores energy in a spring with a force constant of 2.50 0 104 N/m. At position A (xA = 0.100 m), the spring compression is a maximum and the child is momentarily at...
-
Write the binomial probability in words. Then, use a continuity correction to convert the binomial probability to a normal distribution probability. P(x 110)
-
How do visionary leaders articulate and communicate compelling visions that inspire organizational members, stakeholders, and society at large to mobilize towards a shared future state ?
-
A 25-year-old woman has been taking clonazepam every day for 3 years for generalized anxiety disorder. She is in town on vacation but forgot her medication at home. When is she most likely to start...
-
communications plan for hosting an event of your choice. Use bullet points in your response to the following: A timeline to include pre-event communications Use of social media Print, Radio and TV...
Study smarter with the SolutionInn App