|
|
Java beginner
|
Posted: Feb 2, 2006 8:33 PM
|
|
|
Advertisement
|
public class IfElseDemo { public static void main(String[] args) {
int testscore = 76; char grade;
if (testscore >= 90) { grade = 'A'; } else if (testscore >= 80) { grade = 'B'; } else if (testscore >= 70) { grade = 'C'; } else if (testscore >= 60) { grade = 'D'; } else { grade = 'F'; } System.out.println("Grade = " + grade); } } This is the output from the program. Grade = C
what if.. i want to put myself a testscore and not by default as it was in above testscore = 76;... how change it? tnx
|
|