Assignment #35 and Else and If

Code

    /// Name: Ali Kurland
    /// Period: 6
    /// Program Name: Else and If
    /// File Name: ElseAndIf.java
    /// Date Finished: 9/24/2015
    
    /// 1. Else if is determining whether another condition besides the original if statement (the opposite) is true. Else runs a certain line or lines of code on the condition that none of the preceeding if or else if statements are true.
    /// 2. Removing the else part at the beginning of one of the else if statements causes both the if and else lines of code to run. this might be because getting rid of the else in the else if means that the following else is dependent only on the statement directly preceeding it, rather than both of the preceeding statements.
    
    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." );
    		}
    		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." );
    		}
    		else 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

Assignment 35