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...
-
Suppose selected financial data of Edgewater Company and The Ritter Company for 2014 are presented here (in millions). Instructions (a) For each company, compute the following ratios. (1) Current...
-
Lake Company has the following shares outstanding: 20,000 shares of \(\$ 50\) par value, five percent cumulative preferred stock and 80,000 shares of \(\$ 10\) par value common stock. The company...
-
Clark and Shiffer LLP perform activities related to e-commerce consulting and information systems in Vancouver, British Columbia. The firm, which bills $140 per hour for services performed, is in a...
-
Read the overview below and complete the activities that follow. In addition to trade accounts payable, many companies have other types of current liabilities. These include amounts withheld from...
-
The woman A, the captain B, and the sailor C weigh 120, 180, and 160 lb, respectively, and are sitting in the 300-lb skiff, which is gliding through the water with a speed of 1 knot. If the three...
-
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 //...
-
What does it mean that the Walrasian equilibrium price vector in the dynamic Arrow-Hurwicz model is asymptotically globally stable?
-
The market price of a share of preferred stock in $23.68 and the dividend is $2.22. What discount rute did the market use to value the stock?
-
On January 1, Year 10, Company A and Company B formed a new joint venture, Company C. Company A contributed equipment with a book value of $900,000 and a fair value of $2,100,000 for a 50% interest...
-
Write a C program that calculates and displays the factorial of each element in an integer array. 1. In the main function, the program will ask the user to enter the length of array and the elements...
-
Fort Wayne Corporation expects the following revenues, cash expenses, and depreciation charges as a result of its recent opening of an affiliated store in Lansing: YEAR 2 3 5 Revenues $16,000 $20,000...
-
A boy is whirling a rock attached to a string overhead in a horizontal circle. The rock makes a complete loop in 0 . 5 s and the string is 1 m long. What is the tangential velocity of the rock? (...
-
What is a value chain?
-
What services are provided by the provincial and territorial governments?
-
A survey had the following question on it, with the response options below: 1. How wrong do you think it is for someone your age to pick a fight with someone? 0- Very wrong 1- Wrong 2- A little bit...
-
1)You measure 22 turtles' weights, and find they have a mean weight of 49 ounces. Assume the population standard deviation is 3.7 ounces. Based on this, construct a 99% confidence interval for the...
-
Please only help with part (d) and (e) Rening raw gold ore to remove impurities and concentrate gold content usually involves caustic chemicals. One method involves dissolving the gold with a...
Study smarter with the SolutionInn App