Advertisement
Ligh7_of_H3av3n

05. Hair Salon

Oct 15th, 2023
70
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Java 1.65 KB | None | 0 0
  1. package SamiqtIzpit;
  2.  
  3. import java.util.Scanner;
  4.  
  5. public class P05 {
  6.     public static void main(String[] args) {
  7.         Scanner scanner = new Scanner(System.in);
  8.  
  9.         int dailyGoal = Integer.parseInt(scanner.nextLine());
  10.         int moneyCount = 0;
  11.  
  12.         while (moneyCount < dailyGoal) {
  13.             String command = scanner.nextLine();
  14.             if (!command.equals("closed")) {
  15.                 String type = scanner.nextLine();
  16.  
  17.                 if (command.equals("haircut")) {
  18.                     if (type.equals("mens")) {
  19.                         moneyCount += 15;
  20.                     } else if (type.equals("ladies")) {
  21.                         moneyCount += 20;
  22.                     } else if (type.equals("kids")) {
  23.                         moneyCount += 10;
  24.                     }
  25.                 }
  26.  
  27.                 if (command.equals("color")) {
  28.                     if (type.equals("touch up")) {
  29.                         moneyCount += 20;
  30.                     } else if (type.equals("full color")) {
  31.                         moneyCount += 30;
  32.                     }
  33.                 }
  34.             }
  35.  
  36.             if (command.equals("closed")) {
  37.                 break;
  38.             }
  39.         }
  40.  
  41.         if (moneyCount >= dailyGoal) {
  42.             System.out.println("You have reached your target for the day!");
  43.             System.out.println("Earned money: " + moneyCount + "lv.");
  44.         } else {
  45.             int diff = Math.abs(dailyGoal - moneyCount);
  46.             System.out.println("Target not reached! You need " + diff + "lv. more.");
  47.             System.out.println("Earned money: " + moneyCount + "lv.");
  48.         }
  49.     }
  50. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement