446,361 Members | 1,700 Online Need help? Post your question and get tips & solutions from a community of 446,361 IT Pros & Developers. It's quick & easy.

# Issues with Illegal characters =/

 P: 8 I wrote this program to calculate the income tax of a user depending on whether or not they were married: Expand|Select|Wrap|Line Numbers import javax.swing.JOptionPane;   public class Income_Tax {     public static void main (String [] args)     {       String married = "yes";     String single = "no";     String status;     String inputIncome;     int income;     double tax;         status = JOptionPane.showInputDialog("Are you Married? /n(yes or no) /n");       inputIncome = JOptionPane.showInputDialog("Enter your Income : ");       income = Integer.parseInt(inputIncome);       if (status.equals(married))         {             if (income >200300)                 {                     tax = ((651000)*(0.15))+((13145065100)*(0.25))+((200300131450)*(0.28))+((income200300)*(0.33));                }               else if (income >131450 && income <=200300)                 {                     tax = ((651000)*(0.15))+((13145065100)*(0.25))+((income131450)*(0.28));                 }               else if (income >65100 && income <=131450)                   {                     tax = ((651000)*(0.15))+((income65100)*(0.25));                 }               else if (income >0 && income <= 65100)                   {                     tax = ((income0)*(0.15));                 }               else                   {                      JOptionPane.showMessageDialog(null, "\nError: Income cannot be 0 or less ");                 }            }       else if (status.equals(single));         {             if (income >164550)                 {                     tax = ((325500)*(0.15))+((7885032550)*(0.25))+((16455032550)*(0.28))+((income164550)*(0.33));                 }               else if (income >78850 && income <=164550)                 {                     tax = ((325500)*(0.15))+((7885032550)*(0.25))+((income32550)*(0.28));                 }               else if (income >32550 && income <=78850)                   {                     tax = ((325500)*(0.15))+((income32550)*(0.25));                 }               else if (income >0 && income <= 32550)                   {                     tax = ((income0)*(0.15));                 }               else                   {                      JOptionPane.showMessageDialog(null, "\nError: Income cannot be 0 or less ");                 }          }     else         {             JOptionPane.showMessageDialog(null, "\nError: Not a valid answer ");         }       JOptionPane.showMessageDialog(null, "Your income tax is " + tax + " . " );       System.exit(0);        }   }     But, I keep receiving these errors. And I don't know how to fix it ><; So if I could get some help I'd greatly appreciate it! Errors:: Expand|Select|Wrap|Line Numbers Income_Tax.java:30: illegal character: \8211                     tax = ((651000)*(0.15))+((13145065100)*(0.25))+((200300131450)*(0.28))+((income200300)*(0.33));                }                                                      ^ Income_Tax.java:30: illegal character: \8211                     tax = ((651000)*(0.15))+((13145065100)*(0.25))+((200300131450)*(0.28))+((income200300)*(0.33));                }                                                                          ^ Income_Tax.java:30: illegal character: \8211                     tax = ((651000)*(0.15))+((13145065100)*(0.25))+((200300131450)*(0.28))+((income200300)*(0.33));                }                                                                                                  ^ Income_Tax.java:30: illegal character: \8211                     tax = ((651000)*(0.15))+((13145065100)*(0.25))+((200300131450)*(0.28))+((income200300)*(0.33));                }                                                                                                                           ^ Income_Tax.java:30: ')' expected                     tax = ((651000)*(0.15))+((13145065100)*(0.25))+((200300131450)*(0.28))+((income200300)*(0.33));                }                                                                                                                                           ^ Income_Tax.java:34: illegal character: \8211                     tax = ((651000)*(0.15))+((13145065100)*(0.25))+((income131450)*(0.28));                                                      ^ Income_Tax.java:34: illegal character: \8211                     tax = ((651000)*(0.15))+((13145065100)*(0.25))+((income131450)*(0.28));                                                                          ^ Income_Tax.java:34: illegal character: \8211                     tax = ((651000)*(0.15))+((13145065100)*(0.25))+((income131450)*(0.28));                                                                                                  ^ Income_Tax.java:34: ')' expected                     tax = ((651000)*(0.15))+((13145065100)*(0.25))+((income131450)*(0.28));                                                                                                                  ^ Income_Tax.java:40: illegal character: \8211                     tax = ((651000)*(0.15))+((income65100)*(0.25));                                                      ^ Income_Tax.java:40: illegal character: \8211                     tax = ((651000)*(0.15))+((income65100)*(0.25));                                                                          ^ Income_Tax.java:40: ')' expected                     tax = ((651000)*(0.15))+((income65100)*(0.25));                                                                                         ^ Income_Tax.java:46: illegal character: \8211                     tax = ((income0)*(0.15));                                                       ^ Income_Tax.java:46: ')' expected                     tax = ((income0)*(0.15));                                                                  ^ Income_Tax.java:61: illegal character: \8211                     tax = ((325500)*(0.15))+((7885032550)*(0.25))+((16455032550)*(0.28))+((income164550)*(0.33));                                                      ^ Income_Tax.java:61: illegal character: \8211                     tax = ((325500)*(0.15))+((7885032550)*(0.25))+((16455032550)*(0.28))+((income164550)*(0.33));                                                                         ^ Income_Tax.java:61: illegal character: \8211                     tax = ((325500)*(0.15))+((7885032550)*(0.25))+((16455032550)*(0.28))+((income164550)*(0.33));                                                                                                 ^ Income_Tax.java:61: illegal character: \8211                     tax = ((325500)*(0.15))+((7885032550)*(0.25))+((16455032550)*(0.28))+((income164550)*(0.33));                                                                                                                         ^ Income_Tax.java:61: ')' expected                     tax = ((325500)*(0.15))+((7885032550)*(0.25))+((16455032550)*(0.28))+((income164550)*(0.33));                                                                                                                                         ^ Income_Tax.java:66: illegal character: \8211                     tax = ((325500)*(0.15))+((7885032550)*(0.25))+((income32550)*(0.28));                                                      ^ Income_Tax.java:66: illegal character: \8211                     tax = ((325500)*(0.15))+((7885032550)*(0.25))+((income32550)*(0.28));                                                                         ^ Income_Tax.java:66: illegal character: \8211                     tax = ((325500)*(0.15))+((7885032550)*(0.25))+((income32550)*(0.28));                                                                                                 ^ Income_Tax.java:66: ')' expected                     tax = ((325500)*(0.15))+((7885032550)*(0.25))+((income32550)*(0.28));                                                                                                                ^ Income_Tax.java:72: illegal character: \8211                     tax = ((325500)*(0.15))+((income32550)*(0.25));                                                      ^ Income_Tax.java:72: illegal character: \8211                     tax = ((325500)*(0.15))+((income32550)*(0.25));                                                                          ^ Income_Tax.java:72: ')' expected                     tax = ((325500)*(0.15))+((income32550)*(0.25));                                                                                         ^ Income_Tax.java:78: illegal character: \8211                     tax = ((income0)*(0.15));                                                       ^ Income_Tax.java:78: ')' expected                     tax = ((income0)*(0.15));                                                                  ^ Income_Tax.java:87: 'else' without 'if'     else         ^ 29 errors   Thank you so much in advance!! Feb 27 '09 #1
2 Replies

P: 6
I was able to spot four problems in your code dear..
1. its not the generally used subtraction operator you are using. It is something else.. I have no idea what the character is.
2. the semicolon on line 53... that is what is causing the error 'else withou an if', remove that semicolon and you are good
3. variable tax has not been initialised.. give it some initial value like -1
4. convert tax to string before you add it to another string on line 88

I dont have X display do I could only compile it.. i could not run it.. I give you the fixed code.. 'cause I dont know if you will be able to get the correct character for the subtraction operator.. i am attaching it because it may be the display on the browser that's distorting the characters :)

and... please honor the java coding standards... do not use 'underscores' in class names (and method names too for that matter).

regards,
sharat87
Attached Files IncomeTax.zip (762 Bytes, 101 views)
Feb 28 '09 #2

 Expert 10K+ P: 11,448 Check your keyboard: character 8211 (see the error messages) is unicode characer \2013 which is a dash somewhere in the Chinese character set. It may look like an ordinary minus sign but it is a totally different character. kind regards, Jos ps. the other errors are simple unbalanced parentheses errors. Feb 28 '09 #3 