Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- import java.util.Scanner;
- public class TimeConvertor {
- public static void main(String[] args) {
- System.out.println("Hello user! I am time converter program.");
- System.out.println("Just enter what you want to convert : centuries, years, months, weeks, days, hours or minutes! ");
- System.out.print("I want to convert: ");
- Scanner reader = new Scanner(System.in);
- String answerOne = reader.next(); //What does the user convert!
- System.out.println("Excellent! You want to convert " + answerOne + ".");
- System.out.println("How many " + answerOne + " do you want to convert?");
- System.out.print("I want to convert : ");
- double answerTwo = reader.nextDouble(); //The value to convert!
- //Loop begins!
- switch (answerOne) {
- case "minutes":
- System.out.println(answerTwo + " " + answerOne + " are " + (answerTwo / 60) + " hours, " + (answerTwo / 1440) + " days, " + (answerTwo / 10080) + " weeks, " + (answerTwo / 43829) + " months, " +
- (answerTwo / 525949) + " years, " + (answerTwo / 52560000) + " centuries!");
- break;
- case "hours":
- System.out.println(answerTwo + " " + answerOne + " are " + (answerTwo * 60) + " minutes, " + (answerTwo / 24) + " days, " + (answerTwo / 168) + " weeks, " + (answerTwo / 730.485) + " months, " +
- (answerTwo / 8765.82) + " years, " + (answerTwo / 876000) + " centuries!");
- break;
- case "days":
- System.out.println(answerTwo + " " + answerOne + " are " + (answerTwo * 1440) + " minutes, " + (answerTwo * 24) + " hours, " + (answerTwo / 7) + " weeks, " + (answerTwo / 30) + " months, " +
- (answerTwo / 365) + " years, " + (answerTwo / 35600) + " centuries!");
- break;
- case "weeks":
- System.out.println(answerTwo + " " + answerOne + " are " + (answerTwo * 10080) + " minutes, " + (answerTwo * 168) + " hours, " + (answerTwo * 7) + " days, " + (answerTwo / 4.3) + " months, " +
- (answerTwo / 52) + " years, " + (answerTwo / 5214.2) + " centuries!");
- break;
- case "months":
- System.out.println(answerTwo + " " + answerOne + " are " + (answerTwo * 43829.1) + " minutes, " + (answerTwo * 730.485) + " hours, " + (answerTwo * 30.436875) + " days, " + (answerTwo * 4.348125) + " weeks, " +
- (answerTwo / 12) + " years, " + (answerTwo / 1199.2032690614983) + " centuries!");
- break;
- case "years":
- System.out.println(answerTwo + " " + answerOne + " are " + (answerTwo * 525949) + " minutes, " + (answerTwo * 8765) + " hours, " + (answerTwo * 365) + " days, " + (answerTwo * 52) + " weeks, " +
- (answerTwo * 12) + " months, " + (answerTwo / 100) + " centuries!");
- break;
- case "centuries":
- System.out.println(answerTwo + " " + answerOne + " are " + (answerTwo * 52560000) + " minutes, " + (answerTwo * 876000) + " hours, " + " days, " + (answerTwo * 99.9336057551) + (answerTwo * 5214.28571429) + " weeks, " +
- (answerTwo * 1199.20326906) + " months, " + (answerTwo * 36500) + " years!");
- break;
- default:
- System.out.println("Please enter : minutes, hours, days, weeks, months, years or centuries!");
- //Loop finished!
- }
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement