473,405 Members | 2,294 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,405 software developers and data experts.

Switch or If Else statement

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
2 7828
MMcCarthy
14,534 Expert Mod 8TB
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
horace1
1,510 Expert 1GB
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

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

Similar topics

10
by: clueless_google | last post by:
hello. i've been beating my head against a wall over this for too long. setting the variables 'z' or 'y' to differing numbers, the following 'if/else' code snippet works fine; however, the ...
17
by: prafulla | last post by:
Hi all, I don't have a copy of C standard at hand and so anyone of you can help me. I have always wondered how switch statements are so efficient in jumping to the right case (if any)? Can...
12
by: junky_fellow | last post by:
Which is better using a switch statement or the if-then equivalent of switch ?
18
by: swaroophr | last post by:
Which of switch statement and if-else statement takes less time to execute?
13
by: Michael Griebe | last post by:
Simple question. I am optimizing some C++ code and I'd like to know which is faster (or if there is any difference at all) between using a switch statement or nested else-ifs. I'm partial to...
10
by: Evie | last post by:
I understand that when a switch statement is used without breaks, the code continues executing even after a matching case is found. Why, though, are subsequent cases not evaluated? I wrote a...
19
by: rdavis7408 | last post by:
Hello, I have four textboxes that the user enters the price per gallon paid at the pump, the mileage per gallon and I would like to then calculate the cost per gallon and use a switch statement to...
22
by: John | last post by:
Hi Folks, I'm experimenting a little with creating a custom CEdit control so that I can decide on what the user is allowed to type into the control. I started off only allowing floating point...
5
by: mark4asp | last post by:
Every time the function below is called I get the alert. So I put a deliberate error in there and I check the value of (reportType=='MANDATE') in Firebug, which is found to be true. But still the...
13
by: Satya | last post by:
Hi everyone, This is the first time iam posting excuse me if iam making any mistake. My question is iam using a switch case statement in which i have around 100 case statements to compare. so...
0
BarryA
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...
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
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
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows...
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...
0
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing,...
0
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome a new...

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.