title: Avoiding nested if statements
body: <p>I currently have the following code. I am using nested if statements to return different errors based on different cases</p>
  
  <pre><code>if(!cipherFileRead.isEmpty() &amp;&amp; !freqFileRead.isEmpty() ){
  
      if(freqChooser.getSelection()!=null){
  
          if(nearestFreq.isSelected()){
              file.writeToFile(decrypter.nearestFreq(cipherFileRead, freqFileRead), "output.txt");;
          }
          else if (rankingFreq.isSelected()){
              file.writeToFile(decrypter.byRanking(cipherFileRead, freqFileRead), "output.txt");;
          }
  
          returnMessage = "Succesfully decrypted to output.txt";
      }
      else{
          returnMessage = "Please select decryption type. Decryption unsuccesful";}
  }
  else{
      returnMessage = "Both files must be loaded and contain text. Decryption unsuccesful.";}
  
  JOptionPane.showMessageDialog(null, returnMessage);
  }  
  </code></pre>
  
  <p>Is there a more elegant way to achieve this without loads of horrible IF statements?</p>