diff options
| -rw-r--r-- | challenge-194/ziameraj16/java/DigitalClock.java | 33 |
1 files changed, 33 insertions, 0 deletions
diff --git a/challenge-194/ziameraj16/java/DigitalClock.java b/challenge-194/ziameraj16/java/DigitalClock.java new file mode 100644 index 0000000000..27e6797138 --- /dev/null +++ b/challenge-194/ziameraj16/java/DigitalClock.java @@ -0,0 +1,33 @@ +import java.util.Scanner; + +public class DigitalClock { + + public static void main(String[] args) { + Scanner scanner = new Scanner(System.in); + System.out.println("Enter time in format hh:mm"); + String time = scanner.nextLine(); + char first = time.charAt(0); + char second = time.charAt(1); + char third = time.charAt(3); + char fourth = time.charAt(4); + if (first == '?') { + if (Character.getNumericValue(second) > 3) { + System.out.println("Output: 1"); + } else { + System.out.println("Output: 2"); + } + } else if (second == '?') { + if (Character.getNumericValue(first) == 2) { + System.out.println("Output: 3"); + } else { + System.out.println("Output: 9"); + } + } else if (third == '?') { + System.out.println("Output: 5"); + } else if (fourth == '?') { + System.out.println("Output: 9"); + } else { + System.out.println("Invalid time"); + } + } +} |
