- import java.util.Scanner;
- public class Money {
- public static void main (String args[]) {
- Scanner sc= new Scanner(System.in);
- String Name, secondName; //Name is for the first branch, etc.
- int nameOrDenom, firstDenom, secondDenom; //firstDenom is for the first branch, etc.
- System.out.print("Type 1 to enter a last name, 2 to enter a denomination: ");
- nameOrDenom= sc.nextInt();
- if (nameOrDenom == 1) {
- System.out.println("Enter a name: ");
- Name= sc.next();
- if (Name.equals("Jefferson")) {
- System.out.println("What denomination does " + Name + " appear on? ");
- firstDenom= sc.nextInt();
- if((firstDenom == (2)))
- System.out.println("Right!");
- else System.out.println("Wrong!");
- }else if ((Name.equals("Jackson"))) {
- System.out.println("What denomination does " + Name + " appear on? ");
- firstDenom= sc.nextInt();
- if((firstDenom == (20)))
- System.out.println("Right!");
- else System.out.println("Wrong!");
- }else if ((Name.equals("Grant"))) {
- System.out.println("What denomination does " + Name + " appear on? ");
- firstDenom= sc.nextInt();
- if((firstDenom == (50)))
- System.out.println("Right!");
- else System.out.println("Wrong!");
- }else { System.out.println("Invalid name!");} }
- else if (nameOrDenom == 2) {
- System.out.println("Enter a denomination: ");
- secondDenom= sc.nextInt();
- if (secondDenom == 2) {
- System.out.println("Who is on the " + secondDenom +" dollar bill?");
- secondName= sc.next();
- if (secondName.equals("Jefferson"))
- System.out.println("Right!");
- else System.out.println("Wrong!");
- }else if (secondDenom == 20) {
- System.out.println("Who is on the " + secondDenom +" dollar bill?");
- secondName= sc.next();
- if (secondName.equals("Jackson"))
- System.out.println("Right!");
- else System.out.println("Wrong!");
- }else if (secondDenom == 50) {
- System.out.println("Who is on the " + secondDenom +" dollar bill?");
- secondName= sc.next();
- if (secondName.equals("Grant"))
- System.out.println("Right!");
- else System.out.println("Wrong!");
- }else { System.out.println("Invalid choice!"); }
- }
- else System.out.println("Invalid input value!");
- }
- }