Need Help: Simple Java Script won't Compile

Discussion in 'JavaScript' started by jawinn, Sep 4, 2007.

  1. #1
    Hey all. I've been messing around with JAVA for a few days and I have this small script I that I cannot get to compile. Any help is much appreciated.

    
    //UpperToLower
    
    import javax.swing.JOptionPane;
    
    public class UpperToLowerDalziel
    {
      public static void main(String[] args)
      {
        char chUpper, chLower;
    
        while (true)
         {
    
        String dataString = JOptionPane.showInputDialog(null, "Enter Uppercase Character: Enter # to Quit", JOptionPane.QUESTION_MESSAGE);
    
        chUpper = dataString.charAt(0); // Get the first character in string
    
        chLower = upperCaseToLowerCase(chUpper);
    
        String output = "Uppercase " + chUpper + " is " + " Lowercase " + chLower; JOptionPane.showMessageDialog(null, output, "Upper To Lower", JOptionPane.INFORMATION_MESSAGE);
    
        if (chLower == '#') break;
        }
      }
    
    public static char upperCaseToLowerCase(char ch)
      {
      int offset = 32;
    
      if (ch >= 'A' && ch <= 'z');
    
      return (char)(ch + offset);
    
      return ch; <----ERROR
    
      }
    } // End of script
    
    
    
    Code (markup):

     
    jawinn, Sep 4, 2007 IP
  2. ajsa52

    ajsa52 Well-Known Member

    Messages:
    3,426
    Likes Received:
    125
    Best Answers:
    0
    Trophy Points:
    160
    #2
    This forum is related to javascript, not java.
    Anyway, can you post the error message you're getting ?
    Also you should replace if (ch >= 'A' && ch <= 'z'); with if (ch >= 'A' && ch <= 'Z');
    ('Z' should be uppercase, not lowercase).
     
    ajsa52, Sep 5, 2007 IP