Program to calculate discount If customer purchase clothes on Offseason, set discount 15% and on Onseason 40%
 Should use two classes, Onseason and Offseason
 Use two methods- discount(method name should be same)
import java.util.Scanner;
class Onseason{
    static double discounts = 0.4;
    public static void discount(double cost){
        System.out.printf("In season the goods will cost: %.2f", cost*discounts);
        System.out.println("");
    }
}
class Offseason{
    static double discounts = 0.15;
    public static void discount(double cost){
        System.out.printf("Off-season goods will cost: %.2f", cost*discounts);
        System.out.println("");
    }
}
public class Main {
    public static void main(String[] args) {
        Scanner in = new Scanner(System.in);
        System.out.print("Enter cost: ");
        double cost = in.nextDouble();
        Onseason.discount(cost);
        Offseason.discount(cost);
    }
}
Comments