I have looked over this program numerous of times and cant seem to get it running, can some one please guide me in the right direction.
My error information is AnnualSalary.java:33: ' ) ' expected if (AnnualSalary <= 15,000) { - /*
-
* AnnualSalary.java
-
*
-
* Created on September 18, 2007, 9:56 AM
-
*
-
* To change this template, choose Tools | Template Manager
-
* and open the template in the editor.
-
*/
-
-
package AnnualSalary;
-
-
/**
-
*
-
* @author felde301
-
*/
-
import javax.swing.JOptionPane;
-
-
public class AnnualSalary {
-
-
/** Creates a new instance of AnnualSalary */
-
public AnnualSalary() {
-
}
-
-
/**
-
* @param args the command line arguments
-
*/
-
public static void main(String[] args) {
-
JOption.showInputDialog (null,"Enter an annual salary:",
-
JOptionPane.QUESTION_MESSAGE);
-
-
-
-
if (AnnualSalary <= 15,000){
-
-
taxratecategory = '1';
-
-
}else if (AnnualSalary <= 15,000 - 25,000)
-
-
{
-
-
taxratecategory = '2';
-
-
}else if (AnnualSalary => 25,001 - 40,000)
-
{
-
-
taxratecategory = '3';
-
-
}else if (AnnualSalary => 40,0001 - 65,000)
-
{
-
-
taxratecategory = '4';
-
}else if (AnnualSalary => 65,001 - 80,000)
-
{
-
-
taxratecategory = '5';
-
-
}else if (AnnualSalary => 80,000)
-
-
taxratecategory = '6';
-
-
//end if
-
-
//display the result
-
-
JOptionPane.showMessageDialog(null, "The tax rate category for an annual salary");
-
-
-
}
-
-
}
6 2081
I have looked over this program numerous of times and cant seem to get it running, can some one please guide me in the right direction.
My error information is AnnualSalary.java:33: ' ) ' expected if (AnnualSalary <= 15,000) {
/*
* AnnualSalary.java
*
* Created on September 18, 2007, 9:56 AM
*
* To change this template, choose Tools | Template Manager
* and open the template in the editor.
*/
package AnnualSalary;
/**
*
* @author felde301
*/
import javax.swing.JOptionPane;
public class AnnualSalary {
/** Creates a new instance of AnnualSalary */
public AnnualSalary() {
}
/**
* @param args the command line arguments
*/
public static void main(String[] args) {
JOption.showInputDialog (null,"Enter an annual salary:",
JOptionPane.QUESTION_MESSAGE);
if (AnnualSalary <= 15,000){
taxratecategory = '1';
}else if (AnnualSalary <= 15,000 - 25,000)
{
taxratecategory = '2';
}else if (AnnualSalary => 25,001 - 40,000)
{
taxratecategory = '3';
}else if (AnnualSalary => 40,0001 - 65,000)
{
taxratecategory = '4';
}else if (AnnualSalary => 65,001 - 80,000)
{
taxratecategory = '5';
}else if (AnnualSalary => 80,000)
taxratecategory = '6';
//end if
//display the result
JOptionPane.showMessageDialog(null, "The tax rate category for an annual salary");
}
}
1.) Use code tags
2.) Remove all those commas from the amounts.
Edit: And now that I can see the code better under code tags, => is not a valid operator. Use >= instead.
You have to declare variables before you can use them and each variable should have a type.
Thanks for you help I was able to get it running but am not getting the correct output. I should be able to enter a salary and it should tell me waht tax catergory am in.
Output should look like this
Enter an annual salary (ex...40350) => 34400
The tax rate category for an annual salary of $34400 is 3 - /*
-
* AnnualSalary.java
-
*
-
* Created on September 18, 2007, 9:56 AM
-
*
-
* To change this template, choose Tools | Template Manager
-
* and open the template in the editor.
-
*/
-
-
package annualsalary;
-
-
/**
-
*
-
* @author felde301
-
*/
-
import javax.swing.JOptionPane;
-
-
public class AnnualSalary {
-
-
/** Creates a new instance of AnnualSalary */
-
public AnnualSalary() {
-
}
-
-
/**
-
* @param args the command line arguments
-
*/
-
public static void main(String[] args) {
-
-
float annualsalary = 0;
-
float taxratecategory = 0;
-
-
JOptionPane.showInputDialog (null,"Enter an annual salary:",
-
JOptionPane.QUESTION_MESSAGE);
-
-
-
-
if (annualsalary <= 15000){
-
-
taxratecategory = '1';
-
-
}else if (annualsalary <= 15000 - 25000)
-
-
{
-
-
taxratecategory = '2';
-
-
}else if (annualsalary <= 25001 - 40000)
-
{
-
-
taxratecategory = '3';
-
-
}else if (annualsalary <= 400001 - 65000)
-
{
-
-
taxratecategory = '4';
-
}else if (annualsalary <= 65001 - 80000)
-
{
-
-
taxratecategory = '5';
-
-
}else if (annualsalary >= 80000)
-
-
taxratecategory = '6';
-
-
//end if
-
-
//display the result
-
-
JOptionPane.showMessageDialog(null, "The tax rate category for an annual salary");
-
-
-
}
-
-
}
You forgot the code tags again. You have to read what's being replied to you to be able to get the most out of these forums.
-
-
float annualsalary = 0;
-
JOptionPane.showInputDialog (null,"Enter an annual salary:",
-
JOptionPane.QUESTION_MESSAGE);
-
if (annualsalary <= 15000){
-
...
-
}
How is the JOptionPane to know that what you enter there has to be automagically
stuffed into your 'annualsalary' variable? Computers aren't psychic you know.
kind regards,
Jos
.. Computers aren't psychic you know.
kind regards,
Jos
Turing would be disappointed by that statement of course.
Quite an exotic bit of code that by the OP.
Turing would be disappointed by that statement of course.
Nope, Alan Turing already knew that computers are soooo stupid. Even more:
there were no computers in those days; Alan was a clever dicky.
kind regards,
Jos ;-)
Sign in to post your reply or Sign up for a free account.
Similar topics
by: John Ryan |
last post by:
What PHP code would I use to check if submitted sites to my directory
actually exist?? I want to use something that can return the server
code to me, ie HTTP 300 OK, or whatever. Can I do this with...
|
by: Sugapablo |
last post by:
My brain is frozen on a convenient way to figure out if today is the
1st, 2nd, 3rd, 4th, or last Thursday of the month. Basically I need
something that will figure this out for any given day for...
|
by: GazK |
last post by:
I have an image viewing page which resizes an image to a sensible sizebefore
displaying. The user should then be able to choose "25% larger" or smaller
and the resized image display. The problem I...
|
by: george |
last post by:
Guys and girls, I'll be quite honest. I don't have the faintest idea
how to do this, while I can do other php without a problem. Once I
know how to go about it I'll be okay.
It's two things I...
|
by: Phil Powell |
last post by:
....is it not true that mysql_error() will persist? I have a case on a site
where the admin enters a new user and, for some reason, does it wrong,
producing a mysql_error() instance. If they try...
|
by: krystoffff |
last post by:
Hi all !
I've got a very weird problem !
I was trying to make my PHP script to send emails to every subscribed
member to go faster (each email takes 1 or 2 seconds to be sent !) so
I tried to...
|
by: Leif Wessman |
last post by:
I need help creating a regular expression to find the subdomain in the
$HTTP_HOST variable.
The domain is always in this form:
www.domain.com
or
uk.domain.com
or
domain.com
|
by: Sébastien |
last post by:
Hi there,
If I call mergeProfiles() only one time, it is fine. However, if I
call it more than one time (say twice), then it will returns a
segmentation fault... any ideas?
$res is a result...
|
by: Ron Hiler |
last post by:
Hi guys,
I'm a C++ programmer, and I have created a game which has a client/server
architecture. What I would like to do is have my web page show if the
server is up and how many people are...
|
by: sam |
last post by:
Is there a simple way to test if a mysql table exists?
JUST One line !
|
by: taylorcarr |
last post by:
A Canon printer is a smart device known for being advanced, efficient, and reliable. It is designed for home, office, and hybrid workspace use and can also be used for a variety of purposes. However,...
|
by: ryjfgjl |
last post by:
If we have dozens or hundreds of excel to import into the database, if we use the excel import function provided by database editors such as navicat, it will be extremely tedious and time-consuming...
|
by: ryjfgjl |
last post by:
In our work, we often receive Excel tables with data in the same format. If we want to analyze these data, it can be difficult to analyze them because the data is spread across multiple Excel files...
|
by: emmanuelkatto |
last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud.
Please let me know.
Thanks!
Emmanuel
|
by: BarryA |
last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
|
by: nemocccc |
last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
|
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...
|
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...
|
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,...
| |