Advertisement
mrScarlett

Nested If

Nov 30th, 2016
232
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Java 0.90 KB | None | 0 0
  1. import java.util.*;
  2. public class NestedIf
  3. {
  4.     public static void main (String args[]){
  5.         Scanner reader = new Scanner(System.in);  
  6.         System.out.println("Enter favourite food");
  7.         String food = reader.next();
  8.         if (food.equals("Pizza")){
  9.             System.out.println("Whats your favourite topping");
  10.             String topping = reader.next();
  11.             if (topping.equals("Chicken")){
  12.                 System.out.println("Cluck! Cluck!");
  13.             }else if (topping.equals("Pepperoni")){
  14.             System.out.println("That's spicy");
  15.             }else{
  16.              System.out.println("Thats boring");
  17.             }
  18.         }
  19.          else if (food.equals("Rice")){
  20.            
  21.             }
  22.          else if (food.equals("Fried Chicken")){
  23.              
  24.             }
  25.            
  26.          else{
  27.              System.out.println("OK");
  28.             }
  29. }
  30. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement