Created
June 4, 2015 22:44
-
-
Save itsJarrett/7031c40de63c30bf9ace to your computer and use it in GitHub Desktop.
Month to year(s) converter!
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import java.util.Scanner; | |
public class Main { | |
public static void main(String[] args) { | |
monthToYears(); | |
} | |
public static void monthToYears() { | |
Scanner s = new Scanner(System.in); | |
System.out.println("Enter amount of months you want to convert to years."); | |
int months = s.nextInt(); | |
int years = months / 12; | |
months = months % 12; | |
if (months != 0) { | |
System.out.println("That converts to " + years + " year(s)" + " and " + months + " month(s)."); | |
} else { | |
System.out.println("That converts to " + years + " year(s)."); | |
} | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment