We're looking at a clock through the mirror and I want to input what we see in the mirror and get the right clock. For example, the input is 3 55 and output (the actual time) is 09:05 with this conditions 0≤a≤11 0≤b≤59.
I wrote this code:
import java.util.Scanner;
public class Main {
public static void main(String[] args) {
Scanner scanner = new Scanner(System.in);
int a=scanner.nextInt() , b=scanner.nextInt();
int h=(6-a)*2+a , m=(30-b)*2+b;
System.out.printf("%02d:%02d",h,m);
}
}
All inputs are OK except for 0 0. The output is 12:60 which is wrong.