// 9/25/2017
// this file helped with the discussion of block scope
// and nextLine with charAt
// and if else if
// matching nested else to closest if

import java.util.Scanner;

public class nested_if {
  
  public static void main(String[] args)   {
    
       int age;
       String party;
       
       // age is above 18 yrs old, and the person is registered
       // Democrat, since this is a Democratic primary
       
       System.out.print("Enter your party: ");
       Scanner input = new Scanner(System.in);
       party = input.nextLine();
       System.out.print("Enter your age: ");
       age = input.nextInt();
       party.trim(); // get rid of leading spaces
       System.out.println("you entered age: " + age + " party: " 
                            + party.charAt(0));
       
       if (age>=18)
           if (party.charAt(0)=='D') // person is registered democrat
              System.out.println("You are eligible to vote.");
       // else is matched to the CLOSEST unmatched if
           else
              System.out.println("You are not eligible " +
                              "since you are not registered Dem " +
                              "and this is a Democratic primary. ");
       else 
           System.out.println("You are not of age to vote. Pls register "
                                + "when you turn 18 years old." );
       }
}