Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- import java.util.Scanner;
- public class LiveDemo {
- public static void main(String[] args) {
- Scanner scanner = new Scanner(System.in);
- int numberOfSeaExcursion = Integer.parseInt(scanner.nextLine());
- int numberOfMountainExcursion = Integer.parseInt(scanner.nextLine());
- int seaCounter = 0;
- int mountainCounter = 0;
- double profit = 0;
- String command = scanner.nextLine();
- while (!command.equals("Stop")){
- switch (command) {
- case "sea":
- if (seaCounter < numberOfSeaExcursion) {
- seaCounter++;
- profit += 680;
- }
- break;
- case "mountain":
- if (mountainCounter < numberOfMountainExcursion) {
- mountainCounter++;
- profit +=499;
- }
- break;
- }
- if (seaCounter + mountainCounter == numberOfSeaExcursion + numberOfMountainExcursion) {
- break;
- }
- command = scanner.nextLine();
- }
- int totalExcursion = numberOfSeaExcursion + numberOfMountainExcursion;
- int salesExcursion = seaCounter + mountainCounter;
- if (salesExcursion >= totalExcursion){
- System.out.println("Good job! Everything is sold.");
- }
- System.out.printf("Profit: %.0f leva.", profit);
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement