Question: import java.util.Scanner; public class Main { public static void main ( String [ ] args ) { Scanner reader = new Scanner ( System .

import java.util.Scanner;
public class Main {
public static void main(String[] args){
Scanner reader = new Scanner(System.in);
final int TIME_DELAY =45;
final int HOUR_LEN =60;
int absmins =0;
do
{
System.out.print("Enter a timestamp to modify:");
String inputline = reader.nextLine();
try {
String [] tokens = inputline.split("");
int hours = Integer.parseInt(tokens[0]);
int mins = Integer.parseInt(tokens[1]);
absmins =(hours >0)?(hours * HOUR_LEN + mins)- TIME_DELAY: HOUR_LEN + mins - TIME_DELAY;
} catch (java.lang.ArrayIndexOutOfBoundsException e){
System.out.println("Entered too few numbers for a timestamp. Try again.");
continue;
}catch (NumberFormatException e){
System.out.println("Invalid input timestamp. Try again.");
continue;
}
System.out.println("New Timestamp: "+(absmins/HOUR_LEN)+" : "+(absmins%HOUR_LEN));
break;
}while(true);
reader.close();
}
}

Step by Step Solution

There are 3 Steps involved in it

1 Expert Approved Answer
Step: 1 Unlock blur-text-image
Question Has Been Solved by an Expert!

Get step-by-step solutions from verified subject matter experts

Step: 2 Unlock
Step: 3 Unlock

Students Have Also Explored These Related Databases Questions!