By using this site, you agree to our updated Privacy Policy and our Terms of Use. Manage your Cookies Settings.
438,541 Members | 1,109 Online
Bytes IT Community
+ Ask a Question
Need help? Post your question and get tips & solutions from a community of 438,541 IT Pros & Developers. It's quick & easy.

Switch or If Else statement

P: 1
I am a student in Trinidad who must learn and use Java as part of the Diploma in Computer Information Systems. I am having some problems in writing a Java Program for a salary and salary deduction. I have done most of the work and it is just the part where iI take out the decduction weekly which is also compounde weekly that is posing a problem. I am torn between using a swich statement or and if else statement.

If any one can help, I wil be happy to share my source code and and would be grateful for any assistance.

I use Windows XP
Jan 5 '07 #1
Share this Question
Share on Google+
2 Replies


MMcCarthy
Expert Mod 10K+
P: 14,534
I am a student in Trinidad who must learn and use Java as part of the Diploma in Computer Information Systems. I am having some problems in writing a Java Program for a salary and salary deduction. I have done most of the work and it is just the part where iI take out the decduction weekly which is also compounde weekly that is posing a problem. I am torn between using a swich statement or and if else statement.

If any one can help, I wil be happy to share my source code and and would be grateful for any assistance.

I use Windows XP
I am moving this question to the Java forum where it is more likely to be answered.

Mary
Jan 6 '07 #2

Expert 100+
P: 1,510
I am a student in Trinidad who must learn and use Java as part of the Diploma in Computer Information Systems. I am having some problems in writing a Java Program for a salary and salary deduction. I have done most of the work and it is just the part where iI take out the decduction weekly which is also compounde weekly that is posing a problem. I am torn between using a swich statement or and if else statement.

I use Windows XP
Use a switch statement when carrying out a selection based on integral expressions:
Expand|Select|Wrap|Line Numbers
  1.      switch (expression)
  2.          {
  3.           case constant1: statement1
  4.           case constant2: statement2
  5.           case constant3: statement3
  6.           ......
  7.           default: default_statement
  8.          }
  9.  
where expression should evaluate to an integral value (using a cast if necessary) and constant1, constant2, etc. should be integral constant expressions, i.e. which evaluate to an integral constant at compile time.

An if-then-else statement can be used to make decisions based on ranges of values or conditions, e.g. if (a > b), if (a < = b && c > d), etc
Jan 6 '07 #3

Post your reply

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