Assignment 29, Boolean Expressions
Code
///Name: Stella Koliavas
///Period: 5
///Program Name: Boolean Expressions
///File Name: BooleanExperssions.java
///Date Finshed: 10/19/15
import java.util.Scanner;
public class BooleanExpressions
{
public static void main( String[] args)
{
Scanner siri= new Scanner(System.in);
boolean a, b, c,d ,e ,f;
double x, y;
System.out.print("Pick a number");
x= siri.nextDouble();
System.out.print("Pick another number");
y= siri.nextDouble();
a= (x < y);
b= (x <= y);
c= (x == y);
d= (x != y);
e= (x > y);
f= (x >= y);
System.out.println( x + " is LESS THAN " + y + ": " + a );
System.out.println( x + " is LESS THAN or EQUAL TO " + y + ": " + b );
System.out.println( x + " is EQUAL TO " + y + ": " + c );
System.out.println( x + " is NOT EQUAL TO " + y + ": " + d );
System.out.println( x + " is GREATER THAN " + y + ": " + e );
System.out.println( x + " is GREATER THAN or EQUAL TO " + y + ": " + f );
System.out.println();
System.out.println( !(x < y) + " " + (x >= y) );
System.out.println( !(x <= y) + " " + (x > y) );
System.out.println( !(x == y) + " " + (x != y) );
System.out.println( !(x != y) + " " + (x == y) );
System.out.println( !(x > y) + " " + (x <= y) );
System.out.println( !(x >= y) + " " + (x < y) );
}
}
Picture of the output