Results 1 to 2 of 2
- 07-24-2007, 01:29 AM #1
Member
- Join Date
- Jul 2007
- Posts
- 40
- Rep Power
- 0
What is the best way to represent range of number...
Hi, I am new to JAVA and I am trying to write a simple program for a class I have, the one thing I am stuck on (and maybe I am just over-analyzing) is I have to calculate grades.
For example, B = 79%-89% I am thinking that I should use something like this (in pseudo code):
I am not sure if this is the correct way to implement the "and" operator, or if it will work at all any thoughts?Java Code:if iFinalScore >79 && <89 then cFinalGrade=B
Thanks.
- 08-07-2007, 06:13 AM #2
Member
- Join Date
- Jul 2007
- Posts
- 40
- Rep Power
- 0
This can be used if you want the final grade to be stored as a char.
Or as a string.Java Code:char finalGrade; int grade; if(grade>=0 && grade<=69)finalGrade=='F'; else if(grade>=70 && grade<=79)finalGrade=='C'; else if(grade>=80 && grade<=89)finalGrade=='B'; else finalGrade=='A';
Java Code:StringfinalGrade; int grade; if(grade>=0 && grade<=69)finalGrade="F"; else if(grade>=70 && grade<=79)finalGrade="C"; else if(grade>=80 && grade<=89)finalGrade="B"; else finalGrade="A";
Similar Threads
-
The highest number
By I-Shine in forum Java AppletsReplies: 3Last Post: 02-13-2008, 05:05 AM -
line number
By kazitula in forum New To JavaReplies: 3Last Post: 11-21-2007, 10:27 PM -
How to get next available number from MS access
By shahjehan in forum JDBCReplies: 3Last Post: 11-18-2007, 07:41 PM -
how to know the number of the line
By simon in forum New To JavaReplies: 3Last Post: 08-01-2007, 04:59 PM -
Can I set a range in case statement?
By christina in forum New To JavaReplies: 1Last Post: 07-25-2007, 08:41 PM


LinkBack URL
About LinkBacks
Reply With Quote
Bookmarks