Assignemnt #35 and ElseAndIf
Code
///Name: Joshua Bautista
///Period: 6
///Project Name: ElseAndIf
///File Name: ElseANdIf.java
///Date: 10/20/2015
public class ElseAndIf
{
public static void main( String[] args )
{
// The else makes it so that if the if statement is wrong then switch to the else statement
// If you take else out of the else if then it switches to and if, if it is wronge
int people = 30;
int cars = 40;
int buses = 15;
if ( cars > people )
{
System.out.println( "We should take the cars." );
}
if ( cars < people )
{
System.out.println( "We should not take the cars." );
}
else
{
System.out.println( "We can't decide." );
}
if ( buses > cars )
{
System.out.println( "That's too many buses." );
}
if ( buses < cars )
{
System.out.println( "Maybe we could take the buses." );
}
else
{
System.out.println( "We still can't decide." );
}
if ( people > buses )
{
System.out.println( "All right, let's just take the buses." );
}
else
{
System.out.println( "Fine, let's stay home then." );
}
}
}
Picture of the output