Assignemnt #35 Else And If

Code

   
    /// Name: Jake Johnson
    /// Period: 7
    /// Program Name: Else And If
    /// File Name: ElseAndIf.java
    /// Date Finished: 9/29/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 ) //this means that in the situation where cars are not > people and cars < people then execute the following code
		{
			System.out.println( "We should not take the cars." );
		}
		else //this means that none of the above are true, then execude this code
		{
			System.out.println( "We can't decide." );
		}


		if ( buses > cars )
		{
			System.out.println( "That's too many buses." );
		}
		else if ( buses < cars ) //if we remove the else here that would mean that if the first if statement is true, this will also be executed
		{
			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

This should work