Assignemnt #35 Else And If

Code

    ///Name: Prooz Fereydouni
    ///Period: 7
    ///Project Name: Else And If
    ///File Name: ElseAndIf.java
    ///Date: 10/20/2015
  
public class ElseAndIf
{
	public static void main( String[] args )
	{
		int people = 30;
		int cars = 20;
		int buses = 15;

		if ( cars > people )
		{
			System.out.println( "We should take the cars." );
		}
        // else if introduces a new conditional statement only if the previous if statement, "( cars > people )" was not true.
		else if ( cars < people )
		{
			System.out.println( "We should not take the cars." );
		}
        // else introduces a new statement only if the previous if statement, "( cars > people )", and the else if statement, "( cars < people )" are not true.
		else
		{
			System.out.println( "We can't decide." );
		}


		if ( buses > cars )
		{
			System.out.println( "That's too many buses." );
		}
        // without the else the else if statement is not dependent on the previous statement, "( buses > cars ) "
        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

assignment35