Assignemnt #35

Code

                      /// Name: Holden Ganch
                      /// Period: 7
                      /// Program Name: Thirty fifth Program
                      /// File Name: ElseAndIf.java
                      /// Date Finished: 10/8/2015
            
            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." );
          		}
                  /// 'If' line is printed when it is true. 'else if' is printed when if is false and else if is true. 'else' is printed when both 'else' and 'else if' are false
                  
                  /// When removing the 'else' in 'else if' the else line is still not printed for both conditions must be false and there was no 'else if' for it to look for. It also was unable to compile 
          	}
          }

    

Picture of the output

Assignment 35