Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- import java.util.Scanner;
- public class ex11FruitShop {
- public static void main(String[] args) {
- Scanner scanner = new Scanner(System.in);
- String fruit = scanner.nextLine();
- String dayOfWeek = scanner.nextLine();
- double quantity = Double.parseDouble(scanner.nextLine());
- double totalSum = 0.00;
- if (dayOfWeek.equals("Monday") || dayOfWeek.equals("Tuesday")
- || dayOfWeek.equals("Wednesday") || dayOfWeek.equals("Thursday")
- || dayOfWeek.equals("Friday")) {
- if (fruit.equals("banana")) {
- totalSum = 2.50 * quantity;
- } else if (fruit.equals("apple")) {
- totalSum = 1.20 * quantity;
- } else if (fruit.equals("orange")) {
- totalSum = 0.85 * quantity;
- } else if (fruit.equals("grapefruit")) {
- totalSum = 1.45 * quantity;
- } else if (fruit.equals("kiwi")) {
- totalSum = 2.70 * quantity;
- } else if (fruit.equals("pineapple")) {
- totalSum = 5.50 * quantity;
- } else if (fruit.equals("grapes")) {
- totalSum = 3.85 * quantity;
- }
- } else if (dayOfWeek.equals("Saturday") || dayOfWeek.equals("Sunday")) {
- if (fruit.equals("banana")) {
- totalSum = 2.70 * quantity;
- } else if (fruit.equals("apple")) {
- totalSum = 1.25 * quantity;
- } else if (fruit.equals("orange")) {
- totalSum = 0.90 * quantity;
- } else if (fruit.equals("grapefruit")) {
- totalSum = 1.60 * quantity;
- } else if (fruit.equals("kiwi")) {
- totalSum = 3.00 * quantity;
- } else if (fruit.equals("pineapple")) {
- totalSum = 5.60 * quantity;
- } else if (fruit.equals("grapes")) {
- totalSum = 4.20 * quantity;
- }
- }
- if (totalSum != 0) {
- System.out.printf("%.2f", totalSum);
- } else {
- System.out.println("error");
- }
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement