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. Save the application as Billing.java.

Respuesta :

Limosa

Answer:

Following are the program in the Java Programming Language.

//define class

public class Billing

{

//define method  

public static double computeBill(double Price)  

{

//declare variable and initialize the rate method

double taxes = 0.08*Price;

//print the output  

return Price+taxes;

}

//override the following function

public static double computeBill(double Price, int quant) {

//declare double type variable

double taxes = 0.08*(Price*quant);

//return the output

return (quant*Price)+taxes;

}

//override the function

public static double computeBill(double Price, int quant,double value) {

//declare double type variable

double taxes = 0.08*(Price*quant);

//return the output

return ((quant*Price)+taxes)-value;

}

//define main method

public static void main(String args[]) {

//call the following function with argument

System.out.println(computeBill(10));

System.out.println(computeBill(10, 2));

System.out.println(computeBill(10, 20, 50));

}

}

Output:

10.8

21.6

166.0

Explanation:

Following are the description of the program.

  • Define class 'Billing', inside the class we override the following function.
  • Define function 'computeBill()', inside it we calculate tax.
  • Then, override the following function 'computeBill()' and pass the double data type argument 'Price' and integer type 'quant' then, calculate tax.
  • Again, override that function 'computeBill()' and pass the double type arguments 'Price', 'value' and integer type 'quant' then, calculate tax.
  • Finally, define the main method and call the following functions with arguments.