title: Declare decision structure inside of a System.out.println
body: <p>So I am working on an assignment where I have to have a print method in a constructor that displays a distance.
  I also have to have three separate get methods depending on what the input is in the demo class.
  My question is that I am trying to write the print method to contain a decision structure based on which get is used.
      public void prt() {
          DecimalFormat formatter = new DecimalFormat("#,##0.00");</p>
  
  <pre><code>    System.out.println(
          "The time it takes the sound to travel " + distance +
           " feet through air is " + 
  
              if (getSpeedInAir() &gt; 0) {
                  formatter.format(getSpeedInAir());
              }
  
              else if (getSpeedInWater() &gt; 0) {
                  formatter.format(getSpeedInWater());
              }
  
              else if (getSpeedInSteel() &gt; 0) {
                  formatter.format(getSpeedInSteel());
              }
  
              else "error";
      ) 
  }
  </code></pre>
  
  <p>After trying to compile I am getting the following errors.</p>
  
  <pre><code>Microsoft Windows [Version 6.1.7601]
  Copyright (c) 2009 Microsoft Corporation.  All rights reserved.
  
  C:\Users\GlaDOS\Desktop\JavaStuff&gt;j Speed
  
  C:\Users\GlaDOS\Desktop\JavaStuff&gt;del    *.class
  
  C:\Users\GlaDOS\Desktop\JavaStuff&gt;javac  Speed.java
  Speed.java:43: error: illegal start of expression
                                                             " feet through air is
   " + if (getSpeedInAir() &gt; 0)
  
       ^
  Speed.java:43: error: ';' expected
                                                             " feet through air is
   " + if (getSpeedInAir() &gt; 0)
  
         ^
  Speed.java:43: error: not a statement
                                                             " feet through air is
   " + if (getSpeedInAir() &gt; 0)
  
                           ^
  Speed.java:43: error: ';' expected
                                                             " feet through air is
   " + if (getSpeedInAir() &gt; 0)
  
                              ^
  Speed.java:47: error: 'else' without 'if'
  
                                   else if (getSpeedInWater() &gt; 0)
  
                                   ^
  Speed.java:56: error: not a statement
  
                                     "error";)
  
                                     ^
  Speed.java:56: error: illegal start of expression
  
                                     "error";)
  
                                             ^
  7 errors
  
  C:\Users\GlaDOS\Desktop\JavaStuff&gt;java   Speed
  Error: Could not find or load main class Speed
  </code></pre>