Online Java Compiler By
JavaTpoint.com
import java.lang.Double; import java.util.Scanner; public class DoubleCompareToMethodExample2 { public static void main(String[] args) { Double d1 = new Double("35"); Scanner scanner= new Scanner(System.in); System.out.println("Enter your percentage"); Double d2=scanner.nextDouble (); //compares two Double objects numerically int compare=d1.compareTo(d2); if(compare >= 0){ System.out.println(" You are not eligible for the Exam."); } else{ System.out.println("Congrats you are eligible for the Exam."); } }}
Output