Assignment #29 Boolean Expressions
Code
///Name: Ian Grant
///Period:5
///Project Name: Boolean Expressions
///File Name:BoolExp.java
///10/15/15
import java.util.Scanner;
public class BoolExp
{
public static void main(String[] args)
{
Scanner keyboard=new Scanner(System.in);
boolean a,b,c,d,e,f;
double x,y;
System.out.print("Give me two numbers. First: ");
x= keyboard.nextDouble();
System.out.print("Second: ");
y=keyboard.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));
}
}
Output