Assignemnt #35 and Else And If
Code
///Name: Dakota Donahue
///Period: 5
///Project Name: Else And If
///File Name: ElseAndIf
///Date: 8/5/2015
///1. An else if statement is the first alternative to an if statement. if neither the if or else if statement are satisfied, the the else statement will be satisfied.
///2. When the else is removed from the else if statement, it is possible for botht the if and the else statement to be satisfied simulatneously.
public class ElseAndIf
{
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." );
}
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." );
}
}
}