Advertisement
veronikaaa86

05. Excursion Sale

Oct 23rd, 2022
1,345
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Java 1.50 KB | None | 0 0
  1. import java.util.Scanner;
  2.  
  3. public class LiveDemo {
  4.     public static void main(String[] args) {
  5.  
  6.         Scanner scanner = new Scanner(System.in);
  7.  
  8.         int numberOfSeaExcursion = Integer.parseInt(scanner.nextLine());
  9.         int numberOfMountainExcursion = Integer.parseInt(scanner.nextLine());
  10.  
  11.         int seaCounter = 0;
  12.         int mountainCounter = 0;
  13.         double profit = 0;
  14.  
  15.         String command = scanner.nextLine();
  16.  
  17.         while (!command.equals("Stop")){
  18.             switch (command) {
  19.                 case "sea":
  20.                     if (seaCounter < numberOfSeaExcursion) {
  21.                         seaCounter++;
  22.                         profit += 680;
  23.                     }
  24.                     break;
  25.                 case "mountain":
  26.                     if (mountainCounter < numberOfMountainExcursion) {
  27.                         mountainCounter++;
  28.                         profit +=499;
  29.                     }
  30.                     break;
  31.             }
  32.             if (seaCounter + mountainCounter == numberOfSeaExcursion + numberOfMountainExcursion) {
  33.                 break;
  34.             }
  35.             command = scanner.nextLine();
  36.         }
  37.         int totalExcursion = numberOfSeaExcursion + numberOfMountainExcursion;
  38.         int salesExcursion = seaCounter + mountainCounter;
  39.  
  40.         if (salesExcursion >= totalExcursion){
  41.             System.out.println("Good job! Everything is sold.");
  42.         }
  43.         System.out.printf("Profit: %.0f leva.", profit);
  44.  
  45.     }
  46. }
  47.  
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement