I've created a method that takes a time parameter, converts it into seconds, and prints its "fraction" by dividing it by the number of seconds in a day. I need to use printf to make it into a table, but I don't know how to take the fraction the method gives me and put it into a table. When I'm done, the program should print this:
Here is the code I've got so far:
public class FractionOfDay {
static double frac = 0; static double timeSecs = 0;
public static void fractionOfDay( int hour, int minute, int second, char half) {
if (hour == 12 && minute == 0 && second == 0 && half == 'A') {
frac = 0.0000;
System.out.print(frac);
}
else if (half == 'A') {
timeSecs = ((hour * 360) + (minute * 60) + second);
frac = (timeSecs / 86400);
System.out.print(frac);
}
else if (half == 'P') {
timeSecs = ((hour * 3600) + (minute * 60) + second + (12 * 3600));
frac = (timeSecs / 86400);
System.out.print(frac);
}
}
public static void main (String [] args) {
fractionOfDay(12, 0, 0, 'A');
}
}