Online Java Compiler By
JavaTpoint.com
import java.util.Scanner; public class Double_equalsMethodExample2 { public static void main(String[] args) { Double d1 = new Double(2); System.err.println("Q. If an ant has 4 legs.How many legs do 8 ants will have ?\n1.8 Legs \b 2.32 legs \b 3.65legs"); Scanner scanner= new Scanner(System.in); System.out.println("Enter your option "); Double d2 = scanner.nextDouble(); if(d2.equals(d1)){ System.out.println("Your answer is correct!"); } else{ System.out.println("opps! Wrong answer. Try again"); } } }
Output