Question

In: Computer Science

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().

Second function

Create another function named computeBill that receives 2 parameters. It will receive the price of an item and the quantity ordered. It will calculated the total and then add 8.25% sales tax to that and return total due back to main().

Third function

Create a third function names computeBill that receives 3 parameters. It will receive the price of an item, the quantity ordered, and a coupon value. It will then calculate the total, then deduct the coupon amount, and add 8.25% sales tax. It will then return the total due to main().

Prompts and output

The prompts the user are easy to understand. Output is formatted to look like currency

Solutions

Expert Solution

import java.util.Scanner;
public class Billing
{
public double computeBill(double price)
{
return (price+price*0.0825);
}
public double computeBill(double price,int quantity)
{
return (price*quantity+price*quantity*0.0825);
}   
public double computeBill(double price,int quantity,double coupon)
{
double total=price*quantity-coupon;
return (total+total*0.0825);
}   
   public static void main(String[] args)
   {
   Billing b = new Billing();
   Scanner sc = new Scanner(System.in);
       System.out.print("Enter the price: ");
double price1=sc.nextDouble();  
System.out.println("Bill = $"+b.computeBill(price1));
       System.out.print("Enter the price: ");
double price2=sc.nextDouble();  
       System.out.print("Enter the quantity: ");
int quantity=sc.nextInt();  
System.out.println("Bill = $"+b.computeBill(price2,quantity));
        System.out.print("Enter the price: ");
double price3=sc.nextDouble();  
       System.out.print("Enter the quantity: ");
int quantity2=sc.nextInt();
       System.out.print("Enter the coupon value: ");
double coupon=sc.nextDouble();
System.out.println("Bill = $"+b.computeBill(price3,quantity2,coupon));   
   }
}


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...
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...
In java: -Create a class named Animal
In java: -Create a class named Animal
JAVA PROGRAMMING. In this assignment, you are to create a class named Payroll. In the class,...
JAVA PROGRAMMING. In this assignment, you are to create a class named Payroll. In the class, you are to have the following data members: name: String (5 pts) id: String   (5 pts) hours: int   (5 pts) rate: double (5 pts) private members (5 pts) You are to create no-arg and parameterized constructors and the appropriate setters(accessors) and getters (mutators). (20 pts) The class definition should also handle the following exceptions: An employee name should not be empty, otherwise an exception...
in Java, Create a class called EMPLOYEE that includes three instance variables – a first name...
in Java, Create a class called EMPLOYEE that includes three instance variables – a first name (type String), a last name (type String) and a monthly salary (double). Provide a constructor that initializes the three instance variables. Provide a set and a get method for each instance variable. If the monthly salary is not positive, do not set its value. Write a test app names EmployeeTest that demonstrates class EMLOYEE’s capabilities. Create two EMPLOYEE objects and display each object’s yearly...
Create a Java project called Lab3B and a class named Lab3B. Create a second new class...
Create a Java project called Lab3B and a class named Lab3B. Create a second new class named Book. In the Book class: Add the following private instance variables: title (String) author (String) rating (int) Add a constructor that receives 3 parameters (one for each instance variable) and sets each instance variable equal to the corresponding variable. Add a second constructor that receives only 2 String parameters, inTitle and inAuthor. This constructor should only assign input parameter values to title and...
Create a Java project called Lab3A and a class named Lab3A. Create a second new class...
Create a Java project called Lab3A and a class named Lab3A. Create a second new class named Employee. In the Employee class: Add the following private instance variables: name (String) job (String) salary (double) Add a constructor that receives 3 parameters (one for each instance variable) and sets each instance variable equal to the corresponding variable. (Refer to the Tutorial3 program constructor if needed to remember how to do this.) Add a public String method named getName (no parameter) that...
Create a Java project called 5 and a class named 5 Create a second new class...
Create a Java project called 5 and a class named 5 Create a second new class named CoinFlipper Add 2 int instance variables named headsCount and tailsCount Add a constructor with no parameters that sets both instance variables to 0; Add a public int method named flipCoin (no parameters). It should generate a random number between 0 & 1 and return that number. (Important note: put the Random randomNumbers = new Random(); statement before all the methods, just under the...
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...
ADVERTISEMENT
ADVERTISEMENT
ADVERTISEMENT