Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- import java.util.Objects;
- import java.util.Scanner;
- public class WeekendOrWorkingDay {
- public static void main(String[] args) {
- Scanner scanner = new Scanner(System.in);
- String day = scanner.nextLine();
- if (Objects.equals(day, "Monday")
- || Objects.equals(day, "Tuesday")
- || Objects.equals(day, "Wednesday")
- || Objects.equals(day, "Thursday")
- || Objects.equals(day, "Friday")) {
- System.out.println("Working day");
- } else if (Objects.equals(day, "Saturday")
- || Objects.equals(day, "Sunday")) {
- System.out.println("Weekend");
- } else {
- System.out.println("Error");
- }
- }
- }
- Решение със switch:
- import java.util.Scanner;
- public class WeekendOrWorkingDay {
- public static void main(String[] args) {
- Scanner scanner = new Scanner(System.in);
- String day = scanner.nextLine();
- switch (day) {
- case "Monday":
- case "Tuesday":
- case "Wednesday":
- case "Thursday":
- case "Friday":
- System.out.println("Working day");
- break;
- case "Saturday":
- case "Sunday":
- System.out.println("Weekend");
- break;
- default:
- System.out.println("Error");
- break;
- }
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement