Advertisement
Osiris1002

Untitled

Dec 11th, 2022
101
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Java 1.48 KB | None | 0 0
  1. package IZPIT;
  2.  
  3. import java.util.Scanner;
  4.  
  5. public class Excursion_Sale {
  6.     public static void main(String[] args) {
  7.         Scanner scan = new Scanner(System.in);
  8.  
  9.         int numOfExOnSea = Integer.parseInt(scan.nextLine());
  10.         int numOfExMount = Integer.parseInt(scan.nextLine());
  11.         String input = scan.nextLine();
  12.         int totalSum = 0;
  13.  
  14.         while (!"Stop".equals(input)) {
  15.                 String destination = input;
  16.                 switch (destination) {
  17.                     case "sea":
  18.                         if (numOfExOnSea == 0){
  19.                            break;
  20.                         }
  21.                         totalSum += 680;
  22.                         numOfExOnSea--;
  23.                         break;
  24.                     case "mountain":
  25.                         if(numOfExMount == 0){
  26.                             break;
  27.                         }
  28.                         totalSum += 499;
  29.                         numOfExMount--;
  30.                         break;
  31.                 }
  32.                 if (numOfExMount == 0 && numOfExOnSea == 0) {
  33.                     break;
  34.                 }
  35.                 input = scan.nextLine();
  36.             }
  37.  
  38.             if (numOfExMount == 0 && numOfExOnSea == 0) {
  39.                 System.out.println(" Good job! Everything is sold.");
  40.                 System.out.printf("Profit: %d leva.", totalSum);
  41.             } else {
  42.                 System.out.printf("Profit: %d leva.", totalSum);
  43.             }
  44.  
  45.     }
  46. }
  47.  
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement