Advertisement
Sim0o0na

Untitled

Dec 17th, 2016
176
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 3.56 KB | None | 0 0
  1.  
  2.  
  3. import java.util.Scanner;
  4.  
  5. public class TimeConvertor {
  6. public static void main(String[] args) {
  7.  
  8. System.out.println("Hello user! I am time converter program.");
  9. System.out.println("Just enter what you want to convert : centuries, years, months, weeks, days, hours or minutes! ");
  10.  
  11. System.out.print("I want to convert: ");
  12. Scanner reader = new Scanner(System.in);
  13. String answerOne = reader.next(); //What does the user convert!
  14.  
  15. System.out.println("Excellent! You want to convert " + answerOne + ".");
  16. System.out.println("How many " + answerOne + " do you want to convert?");
  17.  
  18. System.out.print("I want to convert : ");
  19. double answerTwo = reader.nextDouble(); //The value to convert!
  20.  
  21. //Loop begins!
  22.  
  23.  
  24.  
  25. switch (answerOne) {
  26.  
  27. case "minutes":
  28.  
  29. System.out.println(answerTwo + " " + answerOne + " are " + (answerTwo / 60) + " hours, " + (answerTwo / 1440) + " days, " + (answerTwo / 10080) + " weeks, " + (answerTwo / 43829) + " months, " +
  30. (answerTwo / 525949) + " years, " + (answerTwo / 52560000) + " centuries!");
  31. break;
  32.  
  33. case "hours":
  34.  
  35. System.out.println(answerTwo + " " + answerOne + " are " + (answerTwo * 60) + " minutes, " + (answerTwo / 24) + " days, " + (answerTwo / 168) + " weeks, " + (answerTwo / 730.485) + " months, " +
  36. (answerTwo / 8765.82) + " years, " + (answerTwo / 876000) + " centuries!");
  37. break;
  38.  
  39. case "days":
  40. System.out.println(answerTwo + " " + answerOne + " are " + (answerTwo * 1440) + " minutes, " + (answerTwo * 24) + " hours, " + (answerTwo / 7) + " weeks, " + (answerTwo / 30) + " months, " +
  41. (answerTwo / 365) + " years, " + (answerTwo / 35600) + " centuries!");
  42. break;
  43.  
  44. case "weeks":
  45. System.out.println(answerTwo + " " + answerOne + " are " + (answerTwo * 10080) + " minutes, " + (answerTwo * 168) + " hours, " + (answerTwo * 7) + " days, " + (answerTwo / 4.3) + " months, " +
  46. (answerTwo / 52) + " years, " + (answerTwo / 5214.2) + " centuries!");
  47. break;
  48.  
  49. case "months":
  50. System.out.println(answerTwo + " " + answerOne + " are " + (answerTwo * 43829.1) + " minutes, " + (answerTwo * 730.485) + " hours, " + (answerTwo * 30.436875) + " days, " + (answerTwo * 4.348125) + " weeks, " +
  51. (answerTwo / 12) + " years, " + (answerTwo / 1199.2032690614983) + " centuries!");
  52. break;
  53.  
  54. case "years":
  55. System.out.println(answerTwo + " " + answerOne + " are " + (answerTwo * 525949) + " minutes, " + (answerTwo * 8765) + " hours, " + (answerTwo * 365) + " days, " + (answerTwo * 52) + " weeks, " +
  56. (answerTwo * 12) + " months, " + (answerTwo / 100) + " centuries!");
  57. break;
  58.  
  59. case "centuries":
  60. System.out.println(answerTwo + " " + answerOne + " are " + (answerTwo * 52560000) + " minutes, " + (answerTwo * 876000) + " hours, " + " days, " + (answerTwo * 99.9336057551) + (answerTwo * 5214.28571429) + " weeks, " +
  61. (answerTwo * 1199.20326906) + " months, " + (answerTwo * 36500) + " years!");
  62. break;
  63.  
  64. default:
  65. System.out.println("Please enter : minutes, hours, days, weeks, months, years or centuries!");
  66.  
  67. //Loop finished!
  68. }
  69. }
  70. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement