Assignemnt #33

Code

///Colin Hinton
///5th Period
///What If
///WhatIf.java
///9/29/2015

class WhatIf
{
    public static void main (String [] args)
    {
        int people = 20;
        int cats = 20;
        int dogs = 15;
        
        if ( people < cats )
        // the text will not display because 20 ! > 20
		{
			System.out.println( "Too many cats!  The world is doomed!" );
		}

		if ( people > cats )
        // the text will not display because 20 !> 20
		{
			System.out.println( "Not many cats!  The world is saved!" );
		}

		if ( people < dogs )
        // the text will not display because 15 !> 20
		{
			System.out.println( "The world is drooled on!" );
		}

		if ( people > dogs )
        // the text will display because 20 > 15
		{
			System.out.println( "The world is dry!" );
		}

		dogs += 5;

		if ( people >= dogs )
        // now that we have added 5 to the dog value people now equals dogs making this line display
		{
			System.out.println( "People are greater than or equal to dogs." );
		}

		if ( people <= dogs )
        // like the line above with the addition of the 5 dogs, people now equal dogs making the line display
		{
			System.out.println( "People are less than or equal to dogs." );
		}

		if ( people == dogs )
        // since the mentioned addition of dogs 20 = 20
		{
			System.out.println( "People are dogs." );
		}
	}
}

// the purpose of the curly brackets around the if statement is to show which functions can be executed based on that if statement. 
Although this program is only using one statement which is System.out.println(), 
it could contain more and would need the brackets to show the reader what is to be executed there with that if statement.

    

Picture of the output

Assignment 1