import java.util.Scanner; import java.lang.Integer; public class Main { // This program will prompt the user for a time in the form hh:mm:ss and // and a distance in miles. public static void main(String [] args) { Scanner keyboard = new Scanner(System.in); System.out.print("Please enter a time in form: hh:mm:ss "); String time = keyboard.nextLine(); int hours = Integer.parseInt(time.substring(0, time.indexOf(":"))); String minSec = time.substring(time.indexOf(":")+1); int minutes = Integer.parseInt(minSec.substring(0, minSec.indexOf(":"))); double seconds = Double.parseDouble(minSec.substring(minSec.indexOf(":")+1)); System.out.print("Please enter a distance that you ran (as the number of miles): "); double miles = keyboard.nextDouble(); // YOUR WORK BEGINS HERE. DO NOT CHANGE ANYTHING ABOVE THIS LINE. // YOUR JOB IS TO COMPLETE THE FORMULAS FOR ANY LINE THAT SAYS "TO DO" // Calculate the number of seconds, given the hours, minutes, and seconds input double totalSeconds = 0; // TO DO System.out.println("Total Seconds: "+ totalSeconds); // Calculate the mile pace for the runner given the total seconds and distance double milePace = 0; // TO DO // Calculate the km pace for the runner double kmPace = 0; // TO DO // Note how the minutes and the seconds are "parsed" out using division and modulus System.out.println("Mile Pace is: " + (int)(milePace/60) + " minute " + (double)(milePace%60) + " seconds"); System.out.println("KM Pace is: " + (int)(kmPace/60) + " minute " + (double)(kmPace%60) + " seconds"); } }