import java.util.Scanner;
public class Nc3 {
public static void main(String[] args) {
Scanner input = new Scanner(System.in);
System.out.println("Enter time of arrival: ");
double time = input.nextDouble();
int arrivalTime;
arrivalTime = 0;
arrivalTime += time;
if (time % 20 != 0) {
time %= 20;
time = 20 - time;
System.out.println(arrivalTime +time);
}
else if (((arrivalTime + time) % 100) == 60.0) {
time += 40;
System.out.println(arrivalTime + time);
}
else
System.out.println("Now - " +arrivalTime);
}
}
I was asked to write a program that gets the input of the current time and give back the hour at which the next bus will leave knowing that a bus leaves every 20 minutes at 00, 20, 40 the problem is that if i input 2243 that represent 22:43 i will get back 2260 instead of 2300