Assignemnt #35: Else and If

Code

    /// Name: Cassie
    /// Period: 6
    /// Program Name: Else and If
    /// File Name: ElseandIf.java
    /// Date Finished: 10/20/2015
    
    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." );
        		}
        		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." );
        		}
                
                // 1. If the conidtions aren't met then the program will move to the else if statement. The program then checks if the conditions apply to either else or if
                // 2. Removing the "else" will cause the program to check this line regardless of whether or not the above if statement's conidtions are met
        
        	}
        }
    

Picture of the output

Assignment 35