Cornelius Eanes's Programming Portal
Assignments (Variables Pt. 3)
[31] Compound Boolean Expressions

Goal: Learn about some more boolean-related operators.

/// Name: Cornelius Eanes
/// Period: 5
/// Program Name: Compound Boolean Expressions
/// File Name: CompoundBooleanExpressions.java
/// Date Finished: Oct 01, 2015

import java.util.Scanner;

public class CompoundBooleanExpressions {

    public static void main(String[] args) {

        Scanner input = new Scanner(System.in);

        int age;
        double income, rating;
        boolean allowed;

        System.out.print("Enter your age: ");
        age = input.nextInt();

        System.out.print("Enter your yearly income: ");
        income = input.nextDouble();

        System.out.print("What would you rate Sword Art Online, from 0.0 to 10.0: ");
        rating = input.nextDouble();

        allowed = age > 25 && age < 40 || (income >= 30000 && rating <= 2.0);

        System.out.println("You are allowed to date my grandchild: " + allowed);

    }

}

Output