Online Java Compiler By
JavaTpoint.com
import java.util.Scanner; public class BooleanToStringExample2 { public static void main(String[] args) { Scanner scanner = new Scanner(System.in); System.out.println("Enter your percentage."); Double d1 = scanner.nextDouble(); Boolean b1 = false; if (d1 > 64) { b1 =true;} String str = b1.toString(); if((str=="true")) { System.out.println("Congratulation! You have passed."); } else {//if(str=="false') double d2=64.0-d1; System.out.println("Sorry! You have failed. You needed "+d2+" more marks to pass .\nTry again next year."); } } }
Output