Assignemnt #31: Compound Boolean

Code

    /// Name: Kelsey Lieberman
    /// Period 5
    /// Program Name: CompoundBoolean
    /// File Name: CompoundBoolean.java
    /// Date Finished: 10/8/2015
    
import java.util.Scanner;

public class CompoundBoolean
{
    public static void main(String[] args)
    {
        Scanner keyboard = new Scanner(System.in);
        
        int age;
        double income, attractiveness;
        boolean allowed;
        
        System.out.print("Enter your age: ");
        age = keyboard.nextInt();
        
        System.out.print("Enter your yearly income: ");
        income = keyboard.nextDouble();
        
        System.out.print("How attractive are you, on a scale from 0.0 to 10.0? ");
        attractiveness = keyboard.nextDouble();
        
        allowed = (age > 25 && age < 40 && (income > 50000 || attractiveness >= 8.5) );
        
        System.out.println("You are allowed to date my grandchild: " + allowed );
    int x = 3 | 5;
    int y = 3 & 5;
    System.out.println(x);
    System.out.println(y);
        ///x = 0011          y = 0011
        ///   |0101             &0101
        ///   =0111 = 7         =0001 = 1
        
        ///for the "OR" operator, the 1s are only transferred if 1s exist in any of the inputs
        ///for the "AND" operator, the 1s are only transferred if all inputs have a 1 in a column
    }
}

    

Picture of the output

Assignment 31