Advertisement
markopizzy

Untitled

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