Program #35

Code

   
    /// Name: Afaf Nabeeha
    /// Period: 7
    /// Program Name: Else and If
    /// File Name: Else.java
    /// Date Finished: 10/20/2015 public class Else

          public class Else
          {
          	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.  I think the else and if statements gives the computer the option to determine an answer between two choices.  If one statement is not true then it means that the other one will be.
          // 2.  When I remove the else part, it doesn't make a difference, it prints the same thing it printed before I removed the else part at the beginning of one of the else it statements.
                      
    

Picture of the output

Assignment 35