EBK JAVA PROGRAMMING
EBK JAVA PROGRAMMING
9th Edition
ISBN: 9781337671385
Author: FARRELL
Publisher: CENGAGE LEARNING - CONSIGNMENT
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…
Modify the student class presented in this chapter as follows. Each student object should also contain the scores for three tests. Provide a constructor that sets all instance values based on parameter values. Overload the constructor such that each test score is assumed to be initially zero. Provide a method called setTestScore that accepts two parameters: the test number (1 through 3) and the score. Also provide a method called getTestScore that accepts the test number and returns the appropriate score Provide a method called average that computes and returns the average test score for this student. Modify the toString method such that the test scores and average are included in the description of the student. Modify the driver class main method to exercise the new Student methods. (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