Answer to Question #320734 in Java | JSP | JSF for Kochu

Question #320734

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)

1
Expert's answer
2022-03-30T07:39:20-0400
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);
    }
}

Need a fast expert's response?

Submit order

and get a quick answer at the best price

for any assignment or question with DETAILED EXPLANATIONS!

Comments

No comments. Be the first!

Leave a comment

LATEST TUTORIALS
New on Blog
APPROVED BY CLIENTS