Assignment #35

Code

///Name: Mahima Choudhary
///Period: 6
///Project Name: ElseAndIf
///File Name: ElseAndIf.java
///Date Finished: 10/16/15

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." );
		}
		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." );
		}

	}
}

        ///When the 'If' is not true then it will move to the 'else if' statement and when that isnt true it will print the 'else' statement if that's true. Removing the Else in front of the if statement makes the statement disappear completely if it isnt true still but the othe statement will show if it is true.

Picture of the output

YourInitials.html