CodePudding user response:
This error is more, youInt grade=80;
Grade=grade>=90? 'a' (grade>=60? "B" : "c");
System. The out. Print (grade);
Reference realization by oneself, not run don't know right,
CodePudding user response:
You are a lot of problems this code, but first you have to understand is how to use conditional operator, use the followingExpression syntax: (to return the result to a Boolean)? The expression 1:2
Returns the result to true expression 1, false expression is executed 2
By looking at your code, probably understand what did you want to do, here is to help you write the code
Int grade=80;//score as an integer
String score="";//result as a string, the result could be a, b
Score=grade>=90? "A" : "b";
System. The out. Println (" achievement is: "+ score);
Above is for you to write code, but look from your code, you need to separate a, b, c three levels of achievement, and conditional operator only corresponding to the two results, so this is recommended if the else, not a condition operators implement
CodePudding user response:
I see road, suggest to find a video website began to learn it from a Java introduction, don't always ask this kind of low-level problem