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