Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- import java.util.Scanner;
- public class Homework11 {
- public static void main(String[] args) {
- Scanner scanner = new Scanner(System.in);
- String input = scanner.nextLine();
- String time = "";
- int hour = 0;
- int minute = 0;
- if (input.length() == 7){
- time = input.substring(input.length()-2);
- hour = Integer.parseInt(input.substring(0, 1));
- minute = Integer.parseInt(input.substring(2, 4));
- } else if (input.length() == 8) {
- time = input.substring(input.length()-2);
- hour = Integer.parseInt(input.substring(0, 2));
- minute = Integer.parseInt(input.substring(3, 5));
- }
- if ("PM".equals(time)) {
- switch (hour) {
- case 0:
- System.out.println("non-beer time");
- break;
- case 1:
- case 2:
- case 3:
- case 4:
- case 5:
- case 6:
- case 7:
- case 8:
- case 9:
- case 10:
- case 11:
- case 12:
- System.out.println("beer time");
- break;
- }
- } else if ("AM".equals(time)) {
- switch (hour) {
- case 0:
- case 1:
- case 2:
- System.out.println("beer time");
- break;
- case 3:
- case 4:
- case 5:
- case 6:
- case 7:
- case 8:
- case 9:
- case 10:
- case 11:
- case 12:
- System.out.println("non-beer time");
- break;
- }
- }
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement