Java USES the nesting of conditional operators to complete the division of academic performance
- 2020-06-12 09:03:07
- OfStack
Use the nesting of conditional operators to complete this problem: academic performance > = students with 90 points are denoted by A, those with 60-89 points are denoted by B, and those with less than 60 points are denoted by C.
Program analysis: (a > b) & # 63; a:b This is a basic example of a conditional operator.
Program design:
import javax.swing.*;
public class ex5 {
public static void main(String[] args){
String str="";
str=JOptionPane.showInputDialog(" Please enter the N Value of (input exit Exit) : ");
int N;
N=0;
try{
N=Integer.parseInt(str);
}
catch(NumberFormatException e){
e.printStackTrace();
}
str=(N>90?"A":(N>60?"B":"C"));
System.out.println(str);
}
}