If Statements

if (rain==y)
System.out.println("Bring umbella");
 
if (rain ==y)
   System.out.println("Bring umbella");
else
   System.out.println("Bring sunglasses");
if (grade > 90)
   System.out.prinln("A+");
else if (grade > 80)
   System.out.prinln("A");
else if (grade > 70) System.out.prinln("B");
else if (grade > 60) System.out.prinln("C");
else if (grade > 50) System.out.prinln("D");
else
System.out.println("Fail");

 

A longer program:

--N U M B E R A N A L Y S I S--

Please enter an integer: -4

The number is even
The number is negative

 

public class choice
{
   public static void main (String args [])
   {
   new choice ();
   }
   public choice ()
   {
   System.out.println ("--N U M B E R A N A L Y S I S--\n");
   int num = IBIO.inputInt ("Please enter an integer: ");
   System.out.println("");

   //Calculate if even or odd
   if (num % 2 == 0)
   	System.out.println ("The number is even");
   else
   	System.out.println ("The number is odd");
   
   //Calculate if negative, zero or positive
   if (num < 0)
   	System.out.println ("The number is negative");
   else if (num == 0)
   	System.out.println ("The number is neither positive nor negative");
   else
   	System.out.println ("The number is positive");
 	}
}