Advertisement
Spocoman

Voleyball

Sep 10th, 2024
287
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Java 0.97 KB | None | 0 0
  1. import java.util.Scanner;
  2.  
  3. public class Main {
  4.     public static void main(String[] args) {
  5.         Scanner scanner = new Scanner(System.in);
  6.         String year = scanner.nextLine();
  7.         double p = Double.parseDouble(scanner.nextLine()),
  8.                 h = Double.parseDouble(scanner.nextLine()),
  9.                 game = ((48 - h) * 3 / 4) + h + p * 2 / 3;
  10.  
  11.         if (year.equals("leap")) {
  12.             game *= 1.15;
  13.         }
  14.  
  15.         System.out.println((int) game);
  16.     }
  17. }
  18.  
  19. ИЛИ:
  20.  
  21. import java.util.Scanner;
  22.  
  23. public class Main {
  24.     public static void main(String[] args) {
  25.         Scanner scanner = new Scanner(System.in);
  26.         String year = scanner.nextLine();
  27.         double p = Double.parseDouble(scanner.nextLine()),
  28.                 h = Double.parseDouble(scanner.nextLine()),
  29.                 game = (((48 - h) * 3 / 4) + h + p * 2 / 3)
  30.                         * (year.equals("leap") ? 1.15 : 1);
  31.  
  32.         System.out.println((int) game);
  33.     }
  34. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement