Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- import java.util.Scanner;
- public class Exam_hair_cut_me {
- public static void main(String[] args) {
- Scanner scanner = new Scanner(System.in);
- int target = Integer.parseInt(scanner.nextLine());
- String input = scanner.nextLine();
- boolean isReached = false;
- // boolean isClosed = false;
- int priceCount = 0;
- while (!"closed".equals(input)) {
- String service = scanner.nextLine();
- if ("haircut".equals(input)) {
- if ("mens".equals(service)) {
- target -= 15;
- priceCount += 15;
- } else if ("ladies".equals(service)) {
- target -= 20;
- priceCount += 20;
- } else if ("kids".equals(service)) {
- target -= 10;
- priceCount += 10;
- }
- } else if ("color".equals(input))
- if ("touch up".equals(service)) {
- target -= 20;
- priceCount += 20;
- } else if ("full color".equals(service)) {
- target -= 30;
- priceCount += 30;
- }
- if (target <= 0) {
- isReached = true;
- break;
- }
- input = scanner.nextLine();
- }
- if (isReached) {
- System.out.println("You have reached your target for the day!");
- System.out.printf("Earned money: %dlv.", priceCount);
- }
- else {
- System.out.printf("Target not reached! You need %dlv. more.%n", target);
- System.out.printf("Earned money: %d", priceCount);
- }
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement