Advertisement
Spocoman

Hair Salon

Sep 7th, 2024
51
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Java 1.23 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 target = Integer.parseInt(scanner.nextLine()),
  7.                 sum = 0;
  8.         String service, category;
  9.  
  10.         while (target > sum && !(service = scanner.nextLine()).equals("closed")) {
  11.             category = scanner.nextLine();
  12.            
  13.             if (service.equals("haircut")) {
  14.                 sum += switch (category) {
  15.                     case "mens" -> 15;
  16.                     case "ladies" -> 20;
  17.                     case "kids" -> 10;
  18.                     default -> 0;
  19.                 };
  20.             } else if (service.equals("color")) {
  21.                 if (category.equals("touch up")) {
  22.                     sum += 20;
  23.                 } else if (category.equals("full color")) {
  24.                     sum += 30;
  25.                 }
  26.             }
  27.         }
  28.  
  29.         if (sum >= target) {
  30.             System.out.println("You have reached your target for the day!");
  31.         } else {
  32.             System.out.println("Target not reached! You need " + (target - sum) + "lv. more.");
  33.         }
  34.         System.out.println("Earned money: " + sum + "lv.");
  35.     }
  36. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement