Question

In: Computer Science

Create a class named Billing that includes three overloaded computeBill() methods for a photo book store....

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.

public class Billing {

    final static double TAX = 0.08;

    public static void main(String[] args) {

        final double HIGHPRICE = 24.99;

        final double MEDPRICE = 17.50;

        final double LOPRICE = 10.00;

        final int QUAN1 = 4;

        final int QUAN2 = 6;

        double bill;

        bill = computeBill(HIGHPRICE);

        System.out.println("The total for a photobook that costs $" +

                           HIGHPRICE + " is $" + bill);

        bill = computeBill(MEDPRICE, QUAN1);

        System.out.println("The total for " + QUAN1 +

                           " photobooks that cost $" +

                           MEDPRICE + " is $" + bill);

        bill = computeBill(LOPRICE, QUAN2, 20.00);

        System.out.println("The total for " + QUAN2 +

                           " photobooks that cost $" +

                           LOPRICE + " with a $20 coupon is $" + bill);

    }

    public static double computeBill(double amt) {

        // Write your code here

        double total = amt * 23.95;

        return total;

    }

    public static double computeBill(double amt, int quantity) {

        // Write your code here

        double subtotal = amt * quantity;

        double total = subtotal * 23.95;

        return total;

    }

    public static double computeBill(double amt, int quantity, double coupon) {

        // Write your code here

        double subtotal = amt * quantity;

        subtotal = subtotal -(subtotal * coupon);

        return subtotal;

    }

}

Solutions

Expert Solution

Explanation:

Here is the corrected code which includes all the methods overloaded with their correct implementation as mentioned above.

Code:

public class Billing{

final static double TAX = 0.08;

public static void main(String[] args) {

final double HIGHPRICE = 24.99;

final double MEDPRICE = 17.50;

final double LOPRICE = 10.00;

final int QUAN1 = 4;

final int QUAN2 = 6;

double bill;

bill = computeBill(HIGHPRICE);

System.out.println("The total for a photobook that costs $" +

HIGHPRICE + " is $" + bill);

bill = computeBill(MEDPRICE, QUAN1);

System.out.println("The total for " + QUAN1 +

" photobooks that cost $" +

MEDPRICE + " is $" + bill);

bill = computeBill(LOPRICE, QUAN2, 20.00);

System.out.println("The total for " + QUAN2 +

" photobooks that cost $" +

LOPRICE + " with a $20 coupon is $" + bill);

}

public static double computeBill(double amt) {

// Write your code here
  
double tax = (0.08 * amt);
  
double total = amt + tax;
  
return total;

}

public static double computeBill(double amt, int quantity) {

// Write your code here

double subtotal = amt * quantity;
  
double tax = (0.08 * subtotal);

double total = subtotal + tax;

return total;

}

public static double computeBill(double amt, int quantity, double coupon) {

// Write your code here

double subtotal = amt * quantity;

subtotal = subtotal - coupon;
  
double tax = (0.08 * subtotal);

double total = subtotal + tax;

return total;

}

}

output:

PLEASE UPVOTE IF YOU FOUND THIS HELPFUL!

PLEASE COMMENT IF YOU NEED ANY HELP!


Related Solutions

Create a class named Billing that includes three overloaded computeBill() methods for a photo book store....
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...
Java Create a class named Billing that includes three overloaded computeBill() methods for a photo book...
Java Create a class named Billing that includes three overloaded computeBill() methods for a photo book store. main() main() will ask the user for input and then call functions to do calculations. The calculations will be returned to main() where they will be printed out. First function Create a function named computeBill that receives on parameter. It receives the price of an item. It will then add 8.25% sales tax to this and return the total due back to main()....
Create “New Class…” named Book to store the details of a book Declare 3 fields for...
Create “New Class…” named Book to store the details of a book Declare 3 fields for the details of the book: field named author of type String field named title of type String field named callNumber of type String Add overloaded constructors with the following headers and make sure each constructor has only 1 statement in the body that makes an internal method call to setBookDetails: public Book(String author, String title, String callNumber) public Book(String author, String title) HINT: Initialize...
Write a class that has three overloaded static methods for calculating the areas of the following...
Write a class that has three overloaded static methods for calculating the areas of the following geometric shapes: - circles - rectangles - cylinders Here are the formulas for calculating the area of the shapes. Area of a circle: Area = π r2, where p is Math.PI and r is the circle's radius Area of a rectangle: Area = Width x Length Area of a cylinder: Area = π r2 h, where p is Math.PI, r is the radius of...
Write a class that has three overloaded static methods for calculating the areas of the following...
Write a class that has three overloaded static methods for calculating the areas of the following geometric shapes: - circles - rectangles - cylinders Here are the formulas for calculating the area of the shapes. Area of a circle: Area = π r2, where p is Math.PI and r is the circle's radius Area of a rectangle: Area = Width x Length Area of a cylinder: Area = π r2 h, where p is Math.PI, r is the radius of...
Create a class named CollegeCourse that includes data fields that hold the department (for example, ENG),...
Create a class named CollegeCourse that includes data fields that hold the department (for example, ENG), the course number (for example, 101), the credits (for example, 3), and the fee for the course (for example, $360). All of the fields are required as arguments to the constructor, except for the fee, which is calculated at $120 per credit hour. Include a display() method that displays the course data. Create a subclass named LabCourse that adds $50 to the course fee....
Create a file named StudentArrayList.java,within the file create a class named StudentArrayList. This class is meant...
Create a file named StudentArrayList.java,within the file create a class named StudentArrayList. This class is meant to mimic the ArrayList data structure. It will hold an ordered list of items. This list should have a variable size, meaning an arbitrary number of items may be added to the list. Most importantly this class should implement the interface SimpleArrayList provided. Feel free to add as many other functions and methods as needed to your class to accomplish this task. In other...
Create a class named UsedFurnitureItem to represent a used furniture item that the store sells. Private...
Create a class named UsedFurnitureItem to represent a used furniture item that the store sells. Private data members of a UsedFurnitureItem are: age (double) // age in years – default value for brandNewPrice (double) // the original price of the item when it was brand new description (string) // a string description of the item condition (char) // condition of the item could be A, B, or C. size (double) // the size of the item in cubic inches. weight...
Create in Java Create a stack class to store integers and implement following methods: 1- void...
Create in Java Create a stack class to store integers and implement following methods: 1- void push(int num): This method will push an integer to the top of the stack. 2- int pop(): This method will return the value stored in the top of the stack. If the stack is empty this method will return -1. 3- void display(): This method will display all numbers in the stack from top to bottom (First item displayed will be the top value)....
Create a custom Exception named IllegalTriangleSideException. Create a class named Triangle. The Triangle class should contain...
Create a custom Exception named IllegalTriangleSideException. Create a class named Triangle. The Triangle class should contain 3 double variables containing the length of each of the triangles three sides. Create a constructor with three parameters to initialize the three sides of the triangle. Add an additional method named checkSides with method header - *boolean checkSides() throws IllegalTriangleSideException *. Write code so that checkSides makes sure that the three sides of the triangle meet the proper criteria for a triangle. It...
ADVERTISEMENT
ADVERTISEMENT
ADVERTISEMENT