Assignemnt #29

Code

/// Name: Ryan Volko
/// Period: 7  
/// Program Name: Boolean Program
/// File Name: Boolean.java
/// Date Finished: 10/6/2015   

import java.util.Scanner;
   
   public class Boolean
   {
       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 + " is equal to " + y + ": " + !(x == y) + " " + x + " is not equal to " + y + ": " + (x != y) );
           System.out.println( !(x != y) + " " + (x == y) );
           System.out.println( x + " is greater or equal " + y + ": " + !(x > y) + " " + x + " is greater than or equal to " + y + ": " + (x <= y) );
           System.out.println( x + " is less than or equal to " + y + ": " + !(x >= y) + x + " is less than " + y + ": " + (x < y) );
           System.out.println( "As you can see some of the program is outputting the opposite of the correct answer");
   
       }
   }
    

Picture of the output

Assignment 29