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 target = Integer.parseInt(scanner.nextLine()),
- sum = 0;
- String service, category;
- while (target > sum && !(service = scanner.nextLine()).equals("closed")) {
- category = scanner.nextLine();
- if (service.equals("haircut")) {
- sum += switch (category) {
- case "mens" -> 15;
- case "ladies" -> 20;
- case "kids" -> 10;
- default -> 0;
- };
- } else if (service.equals("color")) {
- if (category.equals("touch up")) {
- sum += 20;
- } else if (category.equals("full color")) {
- sum += 30;
- }
- }
- }
- if (sum >= target) {
- System.out.println("You have reached your target for the day!");
- } else {
- System.out.println("Target not reached! You need " + (target - sum) + "lv. more.");
- }
- System.out.println("Earned money: " + sum + "lv.");
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement