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