Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- import java.util.*;
- public class NestedIf
- {
- public static void main (String args[]){
- Scanner reader = new Scanner(System.in);
- System.out.println("Enter favourite food");
- String food = reader.next();
- if (food.equals("Pizza")){
- System.out.println("Whats your favourite topping");
- String topping = reader.next();
- if (topping.equals("Chicken")){
- System.out.println("Cluck! Cluck!");
- }else if (topping.equals("Pepperoni")){
- System.out.println("That's spicy");
- }else{
- System.out.println("Thats boring");
- }
- }
- else if (food.equals("Rice")){
- }
- else if (food.equals("Fried Chicken")){
- }
- else{
- System.out.println("OK");
- }
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement