In: Computer Science
For example, if the user has entered ‘true’, display ‘the student has passed the test’, and if the user has entered ‘false’, display ‘the student has failed the test’.
CODE :
import java.util.Scanner;
public class Main
{
public static void main(String[] args) {
System.out.print("Did the student pass the test ? true or false
?");
Scanner obj = new Scanner(System.in);
boolean x = obj.nextBoolean();
if (x == true)
{
System.out.println("The student has passed the test");
}
else if (x != true)
{
System.out.println("The student has failed the test");
}
}
}