desislava_topuzakova

Untitled

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