Assignment #33 and What If

Code

    /// Name: Lauren Baird
    /// Period: 7
    /// Program Name: What If
    /// File Name: WhatIf.java
    /// Date Finished: 10/06/2015
    
    public class WhatIf
    {
        public static void main( String[] args )
        {
            int people = 20;
            int cats = 20;
            int dogs = 15;
            
            // Curly braces hold a statement. It will only run if the "if" statement is correct.
            
            if ( people < cats )
            {
                System.out.println( "Too many cats! The world is doomed!" );
            }
            // Will not print. There are just as many cats as there are people.
            
            if ( people > cats )
            {
                System.out.println( "Not many cats! The world is saved!" );
            }
            // Will not print. The number of cats and people are equal.
            
            if ( people < dogs )
            {
                System.out.println( "The world is drooled on!" );
            }
            // Will not print. There are more people than dogs.
            
            if ( people > dogs )
            {
                System.out.println( "The world is dry!" );
            }
            // Will print. There are more people than dogs.
            
            dogs += 5;
            
            if ( people >= dogs )
            {
                System.out.println( "People are greater than or equal to dogs." );
            }
            // Will print. The number of dogs increased by 5
            
            if ( people <= dogs )
            {
                System.out.println( "People are less than or equal to dogs." );
            }
            // Will print. There are the same number of dogs as people, now.
            
            if ( people == dogs )
            {
                System.out.println( "People are dogs." );
            }
            // Will print. There are just as many people as dogs.
        }
    }

    

Picture of the output

Assignment #33