title: Optimize a simple program
body: <p>So I've programmed for a while and Im a bit confused on how important it is for programs to be "well formatted" I wrote this simple formula program. How can it be "better" written ? In the program you can input some numbers for Einsteins time dilation equation and it outputs how much time has been dilated after a certain amount of time. </p>
  
  <pre><code> import java.util.Scanner;
   import java.lang.Math;
  
  public class Yass {
  Scanner sc = new Scanner(System.in);
  static double velocity;
  static double time;
  static double dilated_time;
  static double dilated_time_Minutes;
  static double dilated_time_Hours;
  static double dilated_time_Days;
  static double dilated_time_Years;
  static boolean timeIsSeconds = false;
  static boolean timeIsMinutes = false;
  static boolean timeIsHours = false;
  static boolean timeIsDays = false;
  static boolean timeIsYears = false;
  public static final double c = 299792.458; // km/s
  
  
  //Time in seconds, velocity in kilometers/second
  
  public Yass(){
  
      getInput();
      executeEquation(time, velocity, c);
  
  }
  
  
  public void executeEquation(double t, double v, double c) {
  
      dilated_time = t / (Math.sqrt(1 - (Math.pow(v, 2) / Math.pow(c, 2))));
  
      if(dilated_time &lt;= 60){
          timeIsSeconds = true;
      }
      if(dilated_time &gt; 60 &amp;&amp; dilated_time &lt; (60*60)){
          dilated_time_Minutes = dilated_time / 60;
          timeIsMinutes = true;
      }
      if(dilated_time &gt; (60*60) &amp;&amp; dilated_time &lt; (60*60)*24){
          dilated_time_Hours = (dilated_time / 60) / 60;
          timeIsHours = true;
      }
      if(dilated_time &gt; (60*60)*24 &amp;&amp; dilated_time &lt; ((60*60)*24)*365){
          dilated_time_Days = ((dilated_time / 60) / 60) / 24;
          timeIsDays = true;
      }
      if(dilated_time &gt; ((60*60)*24)*365){
          dilated_time_Years = (((dilated_time / 60) / 60) / 24) / 365;
          timeIsYears = true;
      }
  }
  
  
  public void getInput(){
      System.out.println("Enter the time you want to measure(stationary) in seconds: ");
      time = sc.nextDouble();
      System.out.println("\n Enter velocity in km/s: ");
      velocity = sc.nextDouble();
  }
  
  
  public static void main(String[] args){
  
      new Yass();
  
      if(timeIsSeconds){
          System.out.println("So if you're in a spaceship and travel at " + velocity + 
                  " km/s. And start a clock who'll measure " + time + " seconds.\nBut at the same time a stationary spaceship start an exact same clock"
                          + " at the same time and measure\nthe same amount of time. After the moving spaceship have measured " + time + " seconds. Then "
                                  + "the stationary\nspaceship will have measured " + dilated_time + " seconds. And therefore time has been running slower for the moving spaceship.");
      }
      if(timeIsMinutes){
          System.out.println("So if you're in a spaceship and travel at " + velocity + 
                  " km/s. And start a clock who'll measure " + time + " seconds.\nBut at the same time a stationary spaceship start an exact same clock"
                          + " at the same time and measure\nthe same amount of time. After the moving spaceship have measured " + time + " seconds. Then "
                                  + "the stationary\nspaceship will have measured " + dilated_time_Minutes + " minutes. And therefore time has been running slower for the moving spaceship.");
      }
      if(timeIsHours){
          System.out.println("So if you're in a spaceship and travel at " + velocity + 
                  " km/s. And start a clock who'll measure " + time + " seconds.\nBut at the same time a stationary spaceship start an exact same clock"
                          + " at the same time and measure\nthe same amount of time. After the moving spaceship have measured " + time + " seconds. Then "
                                  + "the stationary\nspaceship will have measured " + dilated_time_Hours + " hours. And therefore time has been running slower for the moving spaceship.");
      }
      if(timeIsDays){
          System.out.println("So if you're in a spaceship and travel at " + velocity + 
                  " km/s. And start a clock who'll measure " + time + " seconds.\nBut at the same time a stationary spaceship start an exact same clock"
                          + " at the same time and measure\nthe same amount of time. After the moving spaceship have measured " + time + " seconds. Then "
                                  + "the stationary\nspaceship will have measured " + dilated_time_Days + " days. And therefore time has been running slower for the moving spaceship.");
      }
      if(timeIsYears){
          System.out.println("So if you're in a spaceship and travel at " + velocity + 
                  " km/s. And start a clock who'll measure " + time + " seconds.\nBut at the same time a stationary spaceship start an exact same clock"
                          + " at the same time and measure\nthe same amount of time. After the moving spaceship have measured " + time + " seconds. Then "
                                  + "the stationary\nspaceship will have measured " + dilated_time_Years + " years. And therefore time has been running slower for the moving spaceship.");
      }
  }
  }
  </code></pre>
  
  <p>Example:</p>
  
  <p>Enter the time you want to measure(stationary) in seconds:
  10</p>
  
  <p>Enter velocity in km/s: 
  270000</p>
  
  <p>So if you're in a spaceship and travel at 270000.0 km/s. And start a clock who'll measure 10.0 seconds.
  But at the same time a stationary spaceship start an exact same clock at the same time and measure
  the same amount of time. After the moving spaceship have measured 10.0 seconds. Then the stationary
  spaceship will have measured 23.009606245564093 seconds. And therefore time has been running slower for the moving spaceship.</p>