This is my question
- Creat a class named Calculate
- Add 2 instance variables, Quantity & Unit Price
- Add no argument constructor
- Add getters and setters for the 2 instance variables
- Add user defined method named Total with no arguments. Total will calculate and return Quantity * Price. If Quantity is greater than 10, give 5% discount
- Add user defined method to display total amount to the user
- Create a Java main app to create 2 objects based on Calculate class to test the program
So far this is my code:
import java.util.Scanner;
public class Calculate {
public static void main (String args []) {
Scanner Quantity= new Scanner(System.in);
System.out.println(“Enter Quantity”);
double quantity=sc.nextDouble();
System.out.println(“Enter Price”);
double price=sc.nextDouble();
sc.close();
double total=quantity*price;
System.out.println(“The total is:” + total);
}
}