Advertisement
MladenKarachanov

FitnessCard

Nov 27th, 2023
670
-1
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Java 1.83 KB | None | 0 1
  1. package ProgrammingBasics2;
  2.  
  3. import java.util.Scanner;
  4.  
  5. public class FitnessCard {
  6.     public static void main(String[] args) {
  7.         Scanner scanner = new Scanner(System.in);
  8.         double sum = Double.parseDouble(scanner.nextLine());
  9.         String symbol = scanner.nextLine();
  10.         int age = Integer.parseInt(scanner.nextLine());
  11.         String sport = scanner.nextLine();
  12.         double price = 0;
  13.         if (symbol.equals("m")) {
  14.             if (sport.equals("Gum")) {
  15.                 price = 42;
  16.             } else if (sport.equals("Boxing")) {
  17.                 price = 41;
  18.             } else if (sport.equals("Yoga")) {
  19.                 price = 45;
  20.             } else if (sport.equals("Zumba")) {
  21.                 price = 34;
  22.             } else if (sport.equals("Dances")) {
  23.                 price = 51;
  24.             } else if (sport.equals("Pilates")) {
  25.                 price = 39;
  26.             }
  27.         } else if (symbol.equals("f")) {
  28.             if (sport.equals("Gum")) {
  29.                 price = 35;
  30.             } else if (sport.equals("Boxing")) {
  31.                 price = 37;
  32.             } else if (sport.equals("Yoga")) {
  33.                 price = 42;
  34.             } else if (sport.equals("Zumba")) {
  35.                 price = 31;
  36.             } else if (sport.equals("Dances")) {
  37.                 price = 53;
  38.             } else if (sport.equals("Pilates")) {
  39.                 price = 37;
  40.             }
  41.  
  42.  
  43.         }
  44.         if (age <= 19) {
  45.             price = price - (price * 0.20);
  46.         }
  47.         if (sum >= price) {
  48.             System.out.printf("You purchased a 1 month pass for %s.",sport);
  49.         }
  50.         double diff = Math.abs(sum - price);
  51.         if (sum < price) {
  52.             System.out.printf("You don't have enough money! You need $%.2f more.",diff);
  53.         }
  54.     }
  55. }
  56. //НЕ Е РЕШЕНА
  57.  
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement