I'm having some trouble getting the times to show up correctly. inputTime is running fine, but neither displayStandardTime nore displayMilitaryTime is displaying. I've been playing with this for a couple of hours and can't figure it out. I'm probably missing something small, but it's driving me nuts in a big way.
//TimeMain.java
public class TimeMain
{
public static void main(String[] args)
{
Time theTime = new Time();
theTime.inputTime(); //ask user for input
theTime.displayStandardTime(); //show standard time
theTime.displayMilitaryTime(); //show military time
}
}
//Time.Java
import java.util.Scanner;
public class Time
{
private int hour;
private int minute;
private int second;
/*public TimeMain()
{
}*/
public void inputTime()
{
Scanner input = new Scanner(System.in);
//hour input and qualifiers
System.out.print("Enter the hour(s): "); //prompt user for hours
hour = input.nextInt(); //read hour from user
if (hour > 12 || hour < 1)
{
System.out.print("Please enter a value from 1 to 12.");
}
//minute input and qualifiers
System.out.print("Enter the minute(s): "); //prompt user for minutes
minute = input.nextInt(); //read minute from user
if (minute > 60 || minute < 0)
{
System.out.print("Please enter a value from 0 to 60.");
}
//second input and qualifiers
System.out.print("Enter the second(s): "); //prompt user for seconds
second = input.nextInt(); //read second from user
if (second > 60 || second < 0)
{
System.out.print("Please enter a value from 0 to 60.");
}
}
public String displayStandardTime()
{
return "Standard Time: " + hour + ":" + "minute" + ":" + "second";
}
public String displayMilitaryTime()
{
int mhour = hour + 12;
return "Military Time: " + mhour + ":" + "minute" + ":" + "second";
}
}