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)
import javamathBigDecimal public class Account private BigDecimal balance instanc...View the full answer
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...
-
What contemporary design structures does Medtronics seem to utilize?
-
Replacement occurs all at once. LO.1
-
Kiki Company has the following two types of stock: 1. 15,000 shares of 10% cumulative preferred stock with a $30 par value. 2. 30,000 shares of common stock with a $1 par value. Kiki Company declared...
-
Internal Audit is the most common method by which occupational frauds are initially detected. A. True B. False
-
Read the Workplace Policies and Procedures Example - Pinkies Pizza and Pasta A: You witness a fellow staff member cough into his hand. The staff member then picks up pre-made sandwiches (without...
-
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 //...
-
Explain the difference between the estate tax treatment for gift taxes paid on gifts made two years before death and on gifts made ten years before death.
-
Arizona Corp. had the following account balances at 12/1/19: Receivables: $96,000; Inventory: $240,000; Land: $720,000; Building: $600,000; Liabilities: $480,000; Common stock: $120,000; Additional...
-
Construct a 90% confidence interval for the population standard deviation o at Bank A. Bank A 4.2 5.4 5.9 6.1 6.6 7.7 7.7 8.6 9.3 10.0
-
Margin of Error For the poll described in Exercise 1, describe what is meant by the statement that "the margin of error was given as +3.5 percentage points."
-
1) Explain what the critical issue was in the Uber decisions in the First Circuit (Culliane case), and the Second Circuit (Myer case), and how each court, looking at the same facts, came to opposite...
-
IFRS LEASE 1. Kappa Berhad enters into a 10-year lease on 1 January 2020. Kappa Berhad incurred the following costs in respect of the lease: RM2,500 legal fees RM15,000 deposit made at the...
-
If total fixed costs are $200,000 and total variable costs are $100,000 at the output of 20,000 units, what are the probable total fixed costs and total variable costs at an output of 10,000 units?...
-
What steps must a business take to implement a program of social responsibility?
-
En prenant un exemple de votre choix, montrer comment on value un swap de taux de change.
-
How much would you need to invest today in order to receive: a. $10,000 in 5 years at 11%? b. $11,000 in 12 years at 8%? c. $12,000 each year for 10 years at 8%? d. $12,000 at the beginning of each...
-
A company that manufactures pulse Doppler insertion flow meters uses the Straight Line method for book depreciation purposes. Newly acquired equipment has a first cost of $190,000 with a 3-year life...
Study smarter with the SolutionInn App