Assignment #33
Code
///Name: Cody Swain
///Period: 6
///Project Name: WhatIf
///File Name: WhatIf.java
///Date: 10/9/15
public class WhatIf
{
public static void main( String[] args )
{
int people = 30;
int cats = 30;
int dogs = 15;
if ( people < cats )
{
System.out.println( "Too many cats ! The world is doomed!" );
}
if ( people > cats )
{
System.out.println( "Not many cats! The world is saved!" );
}
if (people < dogs )
{
System.out.println( "The world is drooled on!" );
}
if ( people > dogs )
{
System.out.println( "The world is dry" );
}
dogs += 5;
if ( people >= dogs )
{
System.out.println( "People are greater than or equal to dogs." );
}
if ( people <= dogs )
{
System.out.println( "People are less than or equal to dogs." );
}
if (people == dogs )
{
System.out.println( "People are dogs." );
}
}
}
/*
1. The if checks to see if the statement in parenthesis is true, and if it is it executes the code below it.
2. The curly braces in the if statement encase the execute statement. If there were no braces, the those statements would be executed no matter what
3. Value changed to 30 so that people and cats are equal. This makes it so neither statement about cats is executed.
Picture of the output