Mindtap Computing, 1 Term (6 Months) Printed Access Card For Farrell’s Java Programming, 8th
Mindtap Computing, 1 Term (6 Months) Printed Access Card For Farrell’s Java Programming, 8th
8th Edition
ISBN: 9781337091480
Author: Joyce Farrell
Publisher: Cengage Learning
Question
Book Icon
Chapter 4, Problem 2PE
Program Plan Intro

Overloading the “computeBill” method

Program plan:

Filename: “Billing.java”

  • Define the “Billing” class
  • Define the main method.
    • Call the “computeBill” method with single parameter.
    • Call the “computeBill” method with two parameters.
    • Call the “computeBill” method with three parameters.
  • Define the “computeBill” method
    • Calculate the tax value by multiplying “0.08” and “price” value.
    • Return the total due.
  • Define the “computeBill” method
    • Calculate the tax value by multiplying “0.08” and “price” value.
    • Return the total due.
  • Define the overloaded “computeBill” method
    • Calculate the tax value by multiplying “0.08”, “quantity”, and “price” value.
    • Return the total due.
  • Define the “computeBill” method
    • Calculate the tax value by multiplying “0.08”, “quantity”, and “price” value.
    • Return the total due by subtracting the coupon value and tax value.

Blurred answer
Students have asked these similar questions
Modify the Car class example and add the following:  A default constructor that initializes strings to “N/A” and numbers to zero.  An overloaded constructor that takes in initial values to set your fields (6 parameters). accel() method: a void method that takes a double variable as a parameter and increases the speed of the car by that amount. brake() method: a void method that sets the speed to zero.  To test your class, you will need to instantiate at least two different Car objects in the main method in the CarDemo class.  Each of your objects should use a different constructor. For the object that uses the default constructor, you will need to invoke the mutator methods to assign values to your fields. Invoke the displayFeatures() method for both objects and display the variables.  Demonstrate the use of the accessor method getColor() by accessing the color of each car and printing it to the console.  Use the method accel to increase the speed of the first car by 65 mph.  Use…
Create a class named Billing that includes three overloaded computeBill()methods for a photo book store. When computeBill() receives a single parameter, it represents the price of one photo book ordered. Add 8% tax, and return the total due. When computeBill() receives two parameters, they represent the price of a photo book and the quantity ordered. Multiply the two values, add 8% tax, and return the total due. When computeBill() receives three parameters, they represent the price of a photo book, the quantity ordered, and a coupon value. Multiply the quantity and price, reduce the result by the coupon value, and then add 8% tax and return the total due. Write a main() method that tests all three overloaded methods   please write the code in java
Create a class named Billing that includes three overloaded computeBill()methods for a photo book store.•• When computeBill() receives a single parameter, it represents the price ofone photo book ordered. Add 8% tax, and return the total due.•• When computeBill() receives two parameters, they represent the price ofa photo book and the quantity ordered. Multiply the two values, add 8% tax,and return the total due.•• When computeBill() receives three parameters, they represent the price of aphoto book, the quantity ordered, and a coupon value. Multiply the quantityand price, reduce the result by the coupon value, and then add 8% tax andreturn the total due.Write a main() method that tests all three overloaded methods. Save theapplication as Billing.java.
Knowledge Booster
Background pattern image
Similar questions
SEE MORE QUESTIONS
Recommended textbooks for you
  • Text book image
    EBK JAVA PROGRAMMING
    Computer Science
    ISBN:9781337671385
    Author:FARRELL
    Publisher:CENGAGE LEARNING - CONSIGNMENT
Text book image
EBK JAVA PROGRAMMING
Computer Science
ISBN:9781337671385
Author:FARRELL
Publisher:CENGAGE LEARNING - CONSIGNMENT