Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

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

Step: 1

blur-text-image

Get Instant Access to Expert-Tailored Solutions

See step-by-step solutions with expert insights and AI powered tools for academic success

Step: 2

blur-text-image_2

Step: 3

blur-text-image_3

Ace Your Homework with AI

Get the answers you need in no time with our AI-driven, step-by-step assistance

Get Started

Recommended Textbook for

Hands On Database

Authors: Steve Conger

1st Edition

013610827X, 978-0136108276

More Books

Students also viewed these Databases questions

Question

Give examples of authoritative and nonauthoritative U.S. GAAP.

Answered: 1 week ago

Question

What does it mean to be living in poverty?

Answered: 1 week ago