Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- import java.util.Scanner;
- public class Main {
- public static void main(String[] args) {
- Scanner scanner = new Scanner(System.in);
- int seaCount = Integer.parseInt(scanner.nextLine()),
- mountCount = Integer.parseInt(scanner.nextLine()),
- profit = 0;
- String input;
- while (!(input = scanner.nextLine()).equals("Stop")) {
- if (input.equals("sea") && seaCount > 0) {
- profit += 680;
- seaCount--;
- } else if (input.equals("mountain") && mountCount > 0) {
- profit += 499;
- mountCount--;
- }
- if (seaCount + mountCount == 0) {
- System.out.println("Good job! Everything is sold.");
- break;
- }
- }
- System.out.println("Profit: " + profit + " leva.");
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement