Assignment #35
Code
/// Name: Jonathan Stine
/// Period: 5
/// Program Name: Else
/// File Name: Else.java
/// Date Finished: 10/23/2015
public class Else
{
public static void main( String[] args )
{
int people = 30;
int cars = 40;
int buses = 15;
if ( cars > people )
{
System.out.println( "We should take the cars." );
}
else 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." );
}
/// Removing the else in the "else if" above changed nothing.
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." );
}
/// I think else gets printed if the if statements does not. I think else if gets printed if it is true and /// the first if statement was not.
}
}
Code Output