Advertisement
desislava_topuzakova

03. Fitness Card

May 21st, 2018
275
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Java 1.93 KB | None | 0 0
  1. import java.util.Scanner;
  2.  
  3. public class FitnessCard {
  4.     public static void main(String[] agrs) {
  5.         Scanner scanner = new Scanner(System.in);
  6.  
  7.         double sum = Double.parseDouble(scanner.nextLine());
  8.         char gender = scanner.nextLine().charAt(0);
  9.         int age = Integer.parseInt(scanner.nextLine());
  10.         String sport = scanner.nextLine();
  11.  
  12.         double cardPrice = 0;
  13.  
  14.         if (gender == 'm') {
  15.             if (sport.equals("Gym")) {
  16.                 cardPrice = 42;
  17.             } else if (sport.equals("Boxing")) {
  18.                 cardPrice = 41;
  19.             } else if (sport.equals("Yoga")) {
  20.                 cardPrice = 45;
  21.             } else if (sport.equals("Zumba")) {
  22.                 cardPrice = 34;
  23.             } else if (sport.equals("Dances")) {
  24.                 cardPrice = 51;
  25.             } else if (sport.equals("Pilates")) {
  26.                 cardPrice = 39;
  27.             }
  28.         } else if (gender == 'f') {
  29.             switch (sport) {
  30.                 case "Gym":
  31.                     cardPrice = 35;
  32.                     break;
  33.                 case "Boxing":
  34.                     cardPrice = 37;
  35.                     break;
  36.                 case "Yoga":
  37.                     cardPrice = 42;
  38.                     break;
  39.                 case "Zumba":
  40.                     cardPrice = 31;
  41.                     break;
  42.                 case "Dances":
  43.                     cardPrice = 53;
  44.                     break;
  45.                 case "Pilates":
  46.                     cardPrice = 37;
  47.                     break;
  48.             }
  49.         }
  50.  
  51.         if (age <= 19) {
  52.             cardPrice = cardPrice - 0.2 * cardPrice; // 0.8 * cardPrice
  53.         }
  54.  
  55.         if (sum >= cardPrice) {
  56.             System.out.printf("You purchased a 1 month pass for %s.", sport);
  57.         } else {
  58.             System.out.printf("You don't have enough money! You need $%.2f more.", cardPrice - sum);
  59.         }
  60.     }
  61. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement