Assignment #33 What if
Code
///Name: Ian Grant
///Period:5
///Project Name: What if
///File Name:Whatif.java
///10/16/15
public class Whatif
{
public static void main(String[] args)
{
int people=20;
int cats=20;
int dogs=15;
//The if statement if true runs the code within it if its false it doesnt run it and jumps around it.
//The curly braces show what code to run if the statement is true
if (people< cats)
{
System.out.println("Too many cats! The world is rulled by cats now!!");
}
if (people >cats)
{
System.out.println("Not many cats! The world is once again rulled by humans!!");
}
if (people< dogs)
{
System.out.println("Too many dogs! The world is rulled by dogs now!!");
}
if (people >dogs)
{
System.out.println("Not many dogs! The world is once again rulled by humans!!");
}
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 are dogs.");
}
}
}
Output