Advertisement
markopizzy

Untitled

Nov 3rd, 2019
108
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.53 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. int priceCount = 0;
  12.  
  13. while (!"closed".equals(input) || target > 0) {
  14. String service = scanner.nextLine();
  15.  
  16. if ("haircut".equals(input)) {
  17. if ("mens".equals(service)) {
  18. target -= 15;
  19. priceCount += 15;
  20. } else if ("ladies".equals(service)) {
  21. target -= 20;
  22. priceCount += 20;
  23. } else if ("kids".equals(service)) {
  24. target -= 10;
  25. priceCount += 10;
  26. }
  27. } else if ("color".equals(input))
  28. if ("touch up".equals(service)) {
  29. target -= 20;
  30. priceCount += 20;
  31.  
  32. } else if ("full color".equals(service)) {
  33. target -= 30;
  34. priceCount += 30;
  35. }
  36. if (target <= 0) {
  37. isReached = true;
  38. break;
  39. }
  40. input = scanner.nextLine();
  41. }
  42. if (isReached) {
  43. System.out.println("You have reached your target for the day!");
  44. System.out.printf("Earned money: %dlv.", priceCount);
  45. }
  46. }
  47. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement