2. Create a new class that calculates the sales tax on a purchase. (This should be...
Fantastic news! We've Found the answer you've been seeking!
Question:
Transcribed Image Text:
2. Create a new class that calculates the sales tax on a purchase. (This should be similar to the BankAccount class). a. Create a class named SalesTax. b. You will need 4 instance variables: tax, purchasePrice, taxDue, and totalCost. The variable tax will hold the sales tax rate (as a percent value); purchasePrice will hold the price of the item purchased; taxDue wil hold the amount of tax for the purchased item calculated based on the sales tax rate, and totalCost will hold the purchase price plus the tax due. Think about what kind of data each variable will hold to determine what type the variables should be. c. Create 2 constructors. The constructors should be patterned after BankAccount with a default constructor with the tax set to 0 and another constructor that sets the tax equal to the explicit parameter (argument). d. Create a method called calculateSalesTax. (This method should also be similar to deposit in the Bankaccount class). i. This method should accept as input the price of the purchase (a parameter variable called purchase). ii. Use an assignment statement in the body of the method to update the instance variable purchasePrice with the price in the explicit parameter of this method. i. Use the tax rate and the purchase price to calculate the value for the tax due and update the taxDue instance variable. This method will only calculate and store the tax, it will not return anything. e. Create a method called totalCost. This method will not accept any input (no arguments) and will not return anything. i. This method will calculate the total cost by adding the purchase price to the tax due and updating the totalCost instance variable. ii. The method will not return anything. f. Create a method getTotalCost. i.This method has only one purpose and that is to return the totalCost. ii.(Similar to the getBalance method from BankAccount) g. Write a tester class for the SalesTax class. This will be very similar to the BankAccountTester on page 103 of your text. It will have a main ii. Create an object of type SalesTax with an initial sales tax of 10%. iii. Call the calculateSalesTax method. iv. Call the totalCost method. V. Call the getTotalCost method and assign it to a variable called cost. vi. Print the cost. 2. Create a new class that calculates the sales tax on a purchase. (This should be similar to the BankAccount class). a. Create a class named SalesTax. b. You will need 4 instance variables: tax, purchasePrice, taxDue, and totalCost. The variable tax will hold the sales tax rate (as a percent value); purchasePrice will hold the price of the item purchased; taxDue wil hold the amount of tax for the purchased item calculated based on the sales tax rate, and totalCost will hold the purchase price plus the tax due. Think about what kind of data each variable will hold to determine what type the variables should be. c. Create 2 constructors. The constructors should be patterned after BankAccount with a default constructor with the tax set to 0 and another constructor that sets the tax equal to the explicit parameter (argument). d. Create a method called calculateSalesTax. (This method should also be similar to deposit in the Bankaccount class). i. This method should accept as input the price of the purchase (a parameter variable called purchase). ii. Use an assignment statement in the body of the method to update the instance variable purchasePrice with the price in the explicit parameter of this method. i. Use the tax rate and the purchase price to calculate the value for the tax due and update the taxDue instance variable. This method will only calculate and store the tax, it will not return anything. e. Create a method called totalCost. This method will not accept any input (no arguments) and will not return anything. i. This method will calculate the total cost by adding the purchase price to the tax due and updating the totalCost instance variable. ii. The method will not return anything. f. Create a method getTotalCost. i.This method has only one purpose and that is to return the totalCost. ii.(Similar to the getBalance method from BankAccount) g. Write a tester class for the SalesTax class. This will be very similar to the BankAccountTester on page 103 of your text. It will have a main ii. Create an object of type SalesTax with an initial sales tax of 10%. iii. Call the calculateSalesTax method. iv. Call the totalCost method. V. Call the getTotalCost method and assign it to a variable called cost. vi. Print the cost.
Expert Answer:
Answer rating: 100% (QA)
SalesTaxjava package sandboxtax class SalesTax instance variables private double tax private double ... View the full answer
Related Book For
College Accounting A Contemporary Approach
ISBN: 978-0077639730
3rd edition
Authors: David Haddock, John Price, Michael Farina
Posted Date:
Students also viewed these mathematics questions
-
The sales tax on a credit sale is not collected from the customer immediately. When is this tax usually entered in a firm's accounting records? What account is used to record this tax?
-
Create a new class named MyGraph as a subclass of UnweightedGraph that contains a method for finding all connected components in a graph with the following header:public?List>...
-
a. Create a class named BankAccount with fields that hold an account number, the owners name, and the account balance. Include a constructor that initializes each field to appropriate default values....
-
What is the cofactor of an entry of a matrix? How are cofactors used to find the determinant of the matrix?
-
If V is a finite-dimensional vector space and T: V V is a linear transformation such that rank(T) = rank(T2), prove that range(T) ker(T) = {0}.
-
Describe what HAZUS-MH is used for.
-
In March 2015, a Nielsen global online survey "found that consumers are increasingly willing to pay more for socially responsible products." Over 30,000 people in 60 countries were polled about their...
-
Calculating Cash Flows Consider the following abbreviated financial statements for Parrot head Enterprises: a. What is owners?? equity for 2006 and 2007? b. What is the change in net working capital...
-
In January, 1993, there were about 1,313,000 internet hosts. During the next five years, the number of hosts increased by about 100% per year. a. Write a model giving the number h (in millions) of...
-
The Cirrus Co. Plc has the following balances on its books at 31 December 20X9. The following information is also given: 1. The inventory at 31 December 20X9 has been valued at 32,000. Further...
-
Do You Believe That Judicial Review Is A Good Thing For American Democracy? Why Or Why Not?
-
A system has fourteen poles and two zeros. The slope of its highest frequency asymptote in its magnitude plot is (a) - \(40 \mathrm{~dB} /\) decade (b) - \(240 \mathrm{~dB} /\) decade (c) \(-280...
-
The magnitude frequency response of a control system is shown below. The value of \(\omega_{1}\) and \(\omega_{2}\) are respectively (a) 10 and 200 (b) 20 and 200 (c) 20 and 400 (d) 100 and 400 gain...
-
The transfer function of a closed-loop system is \[ \mathrm{T}(s)=\frac{\mathrm{K}}{s^{2}+(3-\mathrm{K}) s+1} \] where \(\mathrm{K}\) is the forward path gain. The root locus plot of the system is...
-
The amplitude ratio \(A(\omega)\) and phase shift function \(\phi(\omega)\) for irrational transfer function \(\mathrm{G}(s)=\frac{e^{-4 s}}{s}\) respectively are (a) \(\mathrm{A}(\omega)=-4 \omega,...
-
The Nyquist plot of \(G(s) H(s)=\frac{10}{s^{2}(1+0.5 s)(1+s)}\) (a) will start \((\omega=\infty)\) in the first quadrant and will terminate \((\omega=0)\) in the second quadrant (b) will start...
-
What is the total property tax bill for your house in Ohio whose market value is $175,000? You are eligible for a $25,000 homestead exemption and the city in which you live has a millage rate of 55...
-
9.Consider the reaction 3NO2(g)+H2O=2HNO3(aq)+NO(g) where Delta H=-137 kJ.How many kilojoules are released when 92.3g of NO2 reacts?
-
Why is a postclosing trial balance prepared?
-
What is the purpose of a credit memorandum?
-
What types of adjustments are reversed?
-
Demonstrate that for a closed path \(\operatorname{Tr} U_{\gamma}(x, x)\) is gauge invariant, where \(U_{\gamma}\left(x_{0}, x_{1} ight)\) is defined by Eq. (26.9).
-
Use Stokes' theorem [Eq. (27.5)] to prove that Eq. (27.4) leads to Eq. (27.6). Data from Eq. 27.4 Data from Eq. 27.5 Data from Eq. 27.6 = z ) ); A dr. - SA dr) = f A dr.
-
Prove the result of Eq. (26.10) that a path-dependent representation of a gauge group is sensitive to a gauge transformation only at the endpoints of the path.
Study smarter with the SolutionInn App