473,396 Members | 2,013 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,396 software developers and data experts.

Issues with Illegal characters =/

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
  1. import javax.swing.JOptionPane;
  2.  
  3. public class Income_Tax
  4. {
  5.     public static void main (String [] args)
  6.     {
  7.  
  8.     String married = "yes";
  9.     String single = "no";
  10.     String status;
  11.     String inputIncome;
  12.     int income;
  13.     double tax;
  14.  
  15.  
  16.     status = JOptionPane.showInputDialog("Are you Married? /n(yes or no) /n");
  17.  
  18.     inputIncome = JOptionPane.showInputDialog("Enter your Income : ");
  19.  
  20.     income = Integer.parseInt(inputIncome);
  21.  
  22.     if (status.equals(married))
  23.         {
  24.             if (income >200300)
  25.                 {
  26.                     tax = ((65100–0)*(0.15))+((131450–65100)*(0.25))+((200300–131450)*(0.28))+((income–200300)*(0.33));                }
  27.  
  28.             else if (income >131450 && income <=200300)
  29.                 {
  30.                     tax = ((65100–0)*(0.15))+((131450–65100)*(0.25))+((income–131450)*(0.28));
  31.                 }
  32.  
  33.             else if (income >65100 && income <=131450)
  34.  
  35.                 {
  36.                     tax = ((65100–0)*(0.15))+((income–65100)*(0.25));
  37.                 }
  38.  
  39.             else if (income >0 && income <= 65100)
  40.  
  41.                 {
  42.                     tax = ((income–0)*(0.15));
  43.                 }
  44.  
  45.             else
  46.  
  47.                 {
  48.                      JOptionPane.showMessageDialog(null, "\nError: Income cannot be 0 or less ");
  49.                 } 
  50.  
  51.         }
  52.  
  53.     else if (status.equals(single));
  54.         {
  55.             if (income >164550)
  56.                 {
  57.                     tax = ((32550–0)*(0.15))+((78850–32550)*(0.25))+((164550–32550)*(0.28))+((income–164550)*(0.33));
  58.                 }
  59.  
  60.             else if (income >78850 && income <=164550)
  61.                 {
  62.                     tax = ((32550–0)*(0.15))+((78850–32550)*(0.25))+((income–32550)*(0.28));
  63.                 }
  64.  
  65.             else if (income >32550 && income <=78850)
  66.  
  67.                 {
  68.                     tax = ((32550–0)*(0.15))+((income–32550)*(0.25));
  69.                 }
  70.  
  71.             else if (income >0 && income <= 32550)
  72.  
  73.                 {
  74.                     tax = ((income–0)*(0.15));
  75.                 }
  76.  
  77.             else
  78.  
  79.                 {
  80.                      JOptionPane.showMessageDialog(null, "\nError: Income cannot be 0 or less ");
  81.                 } 
  82.         }
  83.     else
  84.         {
  85.             JOptionPane.showMessageDialog(null, "\nError: Not a valid answer ");
  86.         }
  87.  
  88.     JOptionPane.showMessageDialog(null, "Your income tax is " + tax + " . " );
  89.  
  90.     System.exit(0); 
  91.  
  92.     }
  93.  
  94. }
  95.  
  96.  
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
  1. Income_Tax.java:30: illegal character: \8211
  2.                     tax = ((65100–0)*(0.15))+((131450–65100)*(0.25))+((200300–131450)*(0.28))+((income–200300)*(0.33));                }
  3.                                                      ^
  4. Income_Tax.java:30: illegal character: \8211
  5.                     tax = ((65100–0)*(0.15))+((131450–65100)*(0.25))+((200300–131450)*(0.28))+((income–200300)*(0.33));                }
  6.                                                                          ^
  7. Income_Tax.java:30: illegal character: \8211
  8.                     tax = ((65100–0)*(0.15))+((131450–65100)*(0.25))+((200300–131450)*(0.28))+((income–200300)*(0.33));                }
  9.                                                                                                  ^
  10. Income_Tax.java:30: illegal character: \8211
  11.                     tax = ((65100–0)*(0.15))+((131450–65100)*(0.25))+((200300–131450)*(0.28))+((income–200300)*(0.33));                }
  12.                                                                                                                           ^
  13. Income_Tax.java:30: ')' expected
  14.                     tax = ((65100–0)*(0.15))+((131450–65100)*(0.25))+((200300–131450)*(0.28))+((income–200300)*(0.33));                }
  15.                                                                                                                                           ^
  16. Income_Tax.java:34: illegal character: \8211
  17.                     tax = ((65100–0)*(0.15))+((131450–65100)*(0.25))+((income–131450)*(0.28));
  18.                                                      ^
  19. Income_Tax.java:34: illegal character: \8211
  20.                     tax = ((65100–0)*(0.15))+((131450–65100)*(0.25))+((income–131450)*(0.28));
  21.                                                                          ^
  22. Income_Tax.java:34: illegal character: \8211
  23.                     tax = ((65100–0)*(0.15))+((131450–65100)*(0.25))+((income–131450)*(0.28));
  24.                                                                                                  ^
  25. Income_Tax.java:34: ')' expected
  26.                     tax = ((65100–0)*(0.15))+((131450–65100)*(0.25))+((income–131450)*(0.28));
  27.                                                                                                                  ^
  28. Income_Tax.java:40: illegal character: \8211
  29.                     tax = ((65100–0)*(0.15))+((income–65100)*(0.25));
  30.                                                      ^
  31. Income_Tax.java:40: illegal character: \8211
  32.                     tax = ((65100–0)*(0.15))+((income–65100)*(0.25));
  33.                                                                          ^
  34. Income_Tax.java:40: ')' expected
  35.                     tax = ((65100–0)*(0.15))+((income–65100)*(0.25));
  36.                                                                                         ^
  37. Income_Tax.java:46: illegal character: \8211
  38.                     tax = ((income–0)*(0.15));
  39.                                                       ^
  40. Income_Tax.java:46: ')' expected
  41.                     tax = ((income–0)*(0.15));
  42.                                                                  ^
  43. Income_Tax.java:61: illegal character: \8211
  44.                     tax = ((32550–0)*(0.15))+((78850–32550)*(0.25))+((164550–32550)*(0.28))+((income–164550)*(0.33));
  45.                                                      ^
  46. Income_Tax.java:61: illegal character: \8211
  47.                     tax = ((32550–0)*(0.15))+((78850–32550)*(0.25))+((164550–32550)*(0.28))+((income–164550)*(0.33));
  48.                                                                         ^
  49. Income_Tax.java:61: illegal character: \8211
  50.                     tax = ((32550–0)*(0.15))+((78850–32550)*(0.25))+((164550–32550)*(0.28))+((income–164550)*(0.33));
  51.                                                                                                 ^
  52. Income_Tax.java:61: illegal character: \8211
  53.                     tax = ((32550–0)*(0.15))+((78850–32550)*(0.25))+((164550–32550)*(0.28))+((income–164550)*(0.33));
  54.                                                                                                                         ^
  55. Income_Tax.java:61: ')' expected
  56.                     tax = ((32550–0)*(0.15))+((78850–32550)*(0.25))+((164550–32550)*(0.28))+((income–164550)*(0.33));
  57.                                                                                                                                         ^
  58. Income_Tax.java:66: illegal character: \8211
  59.                     tax = ((32550–0)*(0.15))+((78850–32550)*(0.25))+((income–32550)*(0.28));
  60.                                                      ^
  61. Income_Tax.java:66: illegal character: \8211
  62.                     tax = ((32550–0)*(0.15))+((78850–32550)*(0.25))+((income–32550)*(0.28));
  63.                                                                         ^
  64. Income_Tax.java:66: illegal character: \8211
  65.                     tax = ((32550–0)*(0.15))+((78850–32550)*(0.25))+((income–32550)*(0.28));
  66.                                                                                                 ^
  67. Income_Tax.java:66: ')' expected
  68.                     tax = ((32550–0)*(0.15))+((78850–32550)*(0.25))+((income–32550)*(0.28));
  69.                                                                                                                ^
  70. Income_Tax.java:72: illegal character: \8211
  71.                     tax = ((32550–0)*(0.15))+((income–32550)*(0.25));
  72.                                                      ^
  73. Income_Tax.java:72: illegal character: \8211
  74.                     tax = ((32550–0)*(0.15))+((income–32550)*(0.25));
  75.                                                                          ^
  76. Income_Tax.java:72: ')' expected
  77.                     tax = ((32550–0)*(0.15))+((income–32550)*(0.25));
  78.                                                                                         ^
  79. Income_Tax.java:78: illegal character: \8211
  80.                     tax = ((income–0)*(0.15));
  81.                                                       ^
  82. Income_Tax.java:78: ')' expected
  83.                     tax = ((income–0)*(0.15));
  84.                                                                  ^
  85. Income_Tax.java:87: 'else' without 'if'
  86.     else
  87.         ^
  88. 29 errors
  89.  

Thank you so much in advance!!
Feb 27 '09 #1
2 17785
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
File Type: zip IncomeTax.zip (762 Bytes, 130 views)
Feb 28 '09 #2
JosAH
11,448 Expert 8TB
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

Sign in to post your reply or Sign up for a free account.

Similar topics

28
by: dingbat | last post by:
I'm writing a "tabbed folder" nav bar. Site standards are graphical prettiness, CSS throughout, valid code, but accesibility is ignored where it conflicts with prettiness. The particular issue...
0
by: MB | last post by:
Hi, I am using a web service to call an asp page on a remote server via System.Net.WebClient . The asp page returns a xml stream persisted from a recordset. I am having problems converting the...
14
by: deko | last post by:
Is there a way to check user input for illegal characters? For example, a user enters something into a text box and clicks OK. At that point I'd like to run code such as this: illegal =...
11
by: Grasshopper | last post by:
Hi, I am automating Access reports to PDF using PDF Writer 6.0. I've created a DTS package to run the reports and schedule a job to run this DTS package. If I PC Anywhere into the server on...
5
by: Dave | last post by:
I need to cut out illegal characters in a string submitted from a mobile phone to a web form. I need a way to check for the illegal characters in a textbox. I intend to loop through the text and...
1
by: Steve Grahovac | last post by:
I have been having trouble the last few days opening any ASP.NET web forms in the design view in the designer. Every time I clicked on an aspx file I got a message box with the error "Unable to...
0
by: Robin Munn | last post by:
I'm developing a simple proof-of-concept Web application, more as a personal programming exercise than anything else, that presents the user with a login form where they can type in a database...
3
by: =?Utf-8?B?SG9seXNtb2tl?= | last post by:
Hi there, I am having a problem im my webservices method when trying to save a file with latin characters to disk passed through WSE. I have noticed that when trying to read the file name from...
6
by: uicouic | last post by:
I have a textbox named "txtName" and a button (btnSave) on a webform. After I have typed the illegal characters into the textbox and click "Save", I would like the webform to check for those...
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
0
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
0
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...
0
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers,...
0
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...
0
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.