In this we are going to see a basic program to check student result using ternary operator in Java Programming Language.
import java.util.Scanner;
public class Test {
public static void main(String[] args) {
Scanner sc = new Scanner(System.in);
System.out.println("Enter your marks: ");
int marks = sc.nextInt();
String result = (marks > 35) ? "passed" : "failed";
System.out.println("You have " + result + " the exam.");
}
}
// Coded by Saahil
#ENJOY CODING
Post a Comment
FOR ANY DOUBTS AND ERRORS FEEL FREE TO ASK. YOUR DOUBTS WILL BE ADDRESSED ASAP