Assignment #35 Else And If

Code

    /// Name: John Huh
    /// Period: 6
    /// Program Name: Else And If
    /// File Name: ElseAndIf.java
    /// Date Finished: 10/1/2015
    
        public class ElseAndIf
        {
            public static void main( String[] args )
            {
            
                // The else if command provides another if statement and if that if statement is true, then it is output.
                // The else command is output if neither the if statement nor the else if statement is true
            
                // The else if statement with the removed else functions the same way
            
                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." );
                }
            }
        }
    

Picture of the output

Assignment 1