Hi, I need help with the following problem
timePeriodMinutes:
This method takes two timestamps (each timestamp is represented by the number of milliseconds that elapsed since January 1, 1970 00:00:00). The method computes the time period between the two timestamps (i.e., the difference between them) in minutes. When computing the time period in minutes, the method rounds up the resulting value. For instance, given inputs 1000000 and 2000000, the method returns 17; and given inputs 2000000 and 1080000, the method returns 16.
The following is the method prototype for the method:
long timePeriodMinutes(long timestamp1, long timestamp2)
If timestamp1 or timestamp2 is negative, the method should indicate an error condition by returning -1.
Please submit your code below.
class studentSubmission {
long timePeriodMinutes(long timestamp1, long timestamp2) {
}
}
I have managed to come with my version of the solution which runs (shown below). However I am failing to conform to the strict requirement of structuring the method according to instructions above.
Code:import java.util.Scanner;
public class studentSub
{
public static void main(String[] args)
{
double timePeriodMinutes;
long timestamp1, timestamp2;
System.out.println("Enter Two timestamps :");
Scanner keyboard = new Scanner(System.in);
timestamp1 = keyboard.nextInt();
timestamp2 = keyboard.nextInt();
if ((timestamp1<0) || (timestamp2<0)) {
System.out.println("Error -1");
} else {
timePeriodMinutes = Math.ceil((timestamp1-timestamp2)/(1000 *60));
timePeriodMinutes = Math.abs(timePeriodMinutes);
System.out.println(timePeriodMinutes + " minutes");
}
}
}
Please someone help

