Results 1 to 6 of 6
Thread: If statement, please help??
- 11-23-2008, 02:59 PM #1
Member
- Join Date
- Oct 2008
- Posts
- 39
- Rep Power
- 0
If statement, please help??
I am also having problems with my if statement, any advise?
public class Level{
public static void main (String[]arg){
int percentage;
char grade;
System.out.println("What percentage did you achieve?");
percentage=UserInput.readInt;
if (percentage >=70<100) {
grade= 'D';
} else if (percentage =>60) {
grade= 'M';
} else if (percentage =>40) {
grade= 'P';
} else if (percentage =>35) {
grade= 'N';
} else if (percentage =>0) {
grade= 'F';
} else if (percentage =<-1 101>) {
grade= 'M';
}
- 11-23-2008, 03:03 PM #2
Senior Member
- Join Date
- Aug 2008
- Posts
- 384
- Rep Power
- 12
What do you want to do with these statements?
Java Code:if (percentage >=70<100) else if (percentage =<-1 101>)
Java Code:if (percentage >=70 && percentage < 100)
Java Code:else if (percentage <= -1 || percentage > 101)
|| means ORI die a little on the inside...
Every time I get shot.
- 11-23-2008, 03:15 PM #3
Member
- Join Date
- Oct 2008
- Posts
- 39
- Rep Power
- 0
Thanks, nice games by the way!!!
now its stating illegal expression tho?
if (percentage >=70 && <100) {
grade= 'D';
-
what is less than 100 here?
Understand that you have two different statements that are being checked for equality, this:
percentage >= 70
and this
< 100
You never specify exactly what is being tested to be less than 100.
- 11-23-2008, 03:55 PM #5
A word of advise..
Fubarable... you may want to reconsider how much effort you put into Soc86 code/questions...
- He/she has absolutely no idea what he/she is doing... no basic programming knowledge, much less java.
- Suggestions given before have been ignored.
see my comments:
http://www.java-forums.org/new-java/...my-switch.html
http://www.java-forums.org/new-java/...lp-please.html
I'm not saying that Soc86 shouldn't get any help, but I'm afraid what help is given will not be understood.... on top of that, I'm starting to get the idea that Soc86 might be looking for the gimme-working-code sorta stuff (I hope I'm wrong about this).
CJSLChris S.
Difficult? This is Mission Impossible, not Mission Difficult. Difficult should be easy.
-
Similar Threads
-
If statement demo
By Java Tip in forum java.langReplies: 0Last Post: 04-23-2008, 09:05 PM -
Switch Statement Help
By bluegreen7hi in forum New To JavaReplies: 6Last Post: 02-06-2008, 06:16 AM -
Help with if statement
By carl in forum New To JavaReplies: 1Last Post: 08-06-2007, 08:53 AM -
Statement or Prepared Statement ?
By paty in forum JDBCReplies: 3Last Post: 08-01-2007, 05:45 PM -
If Statement
By aDrizzle in forum New To JavaReplies: 4Last Post: 07-08-2007, 09:55 PM
Bookmarks