Advertisement
Spocoman

Excursion Sale

Sep 5th, 2024
231
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Java 0.88 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.         int seaCount = Integer.parseInt(scanner.nextLine()),
  7.                 mountCount = Integer.parseInt(scanner.nextLine()),
  8.                 profit = 0;
  9.  
  10.         String input;
  11.         while (!(input = scanner.nextLine()).equals("Stop")) {
  12.             if (input.equals("sea") && seaCount > 0) {
  13.                 profit += 680;
  14.                 seaCount--;
  15.             } else if (input.equals("mountain") && mountCount > 0) {
  16.                 profit += 499;
  17.                 mountCount--;
  18.             }
  19.  
  20.             if (seaCount + mountCount == 0) {
  21.                 System.out.println("Good job! Everything is sold.");
  22.                 break;
  23.             }
  24.         }
  25.  
  26.         System.out.println("Profit: " + profit + " leva.");
  27.     }
  28. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement