Don't like ads? PRO users don't see any ads ;-)
Guest

Untitled

By: a guest on May 18th, 2012  |  syntax: None  |  size: 2.31 KB  |  hits: 22  |  expires: Never
download  |  raw  |  embed  |  report abuse  |  print
Text below is selected. Please press Ctrl+C to copy to your clipboard. (⌘+C on Mac)
  1. import java.util.Scanner;
  2.  
  3. public class Money {
  4.  
  5.   public static void main (String args[]) {  
  6.         Scanner sc= new Scanner(System.in);
  7.         String Name, secondName;                                                //Name is for the first branch, etc.
  8.         int nameOrDenom, firstDenom, secondDenom;               //firstDenom is for the first branch, etc.
  9.          
  10.         System.out.print("Type 1 to enter a last name, 2 to enter a denomination: ");
  11.         nameOrDenom= sc.nextInt();
  12.        
  13.                 if (nameOrDenom == 1) {
  14.                         System.out.println("Enter a name: ");
  15.                         Name= sc.next();
  16.                                
  17.                         if (Name.equals("Jefferson")) {
  18.                                 System.out.println("What denomination does " + Name + " appear on? ");
  19.                                 firstDenom= sc.nextInt();
  20.                                         if((firstDenom == (2)))
  21.                                                 System.out.println("Right!");
  22.                                         else System.out.println("Wrong!");
  23.                                
  24.                                
  25.                         }else if ((Name.equals("Jackson"))) {
  26.                                 System.out.println("What denomination does " + Name + " appear on? ");
  27.                                 firstDenom= sc.nextInt();
  28.                                         if((firstDenom == (20)))
  29.                                                 System.out.println("Right!");
  30.                                         else System.out.println("Wrong!");
  31.                                
  32.                         }else if ((Name.equals("Grant"))) {
  33.                                 System.out.println("What denomination does " + Name + " appear on? ");
  34.                                 firstDenom= sc.nextInt();
  35.                                         if((firstDenom == (50)))
  36.                                                 System.out.println("Right!");
  37.                                         else System.out.println("Wrong!");     
  38.                        
  39.                         }else { System.out.println("Invalid name!");}   }
  40.                        
  41.                
  42.                
  43.                 else if (nameOrDenom == 2) {
  44.                         System.out.println("Enter a denomination: ");
  45.                         secondDenom= sc.nextInt();
  46.                        
  47.                                 if (secondDenom == 2) {
  48.                                         System.out.println("Who is on the " + secondDenom +" dollar bill?");
  49.                                         secondName= sc.next();
  50.                                                 if (secondName.equals("Jefferson"))
  51.                                                         System.out.println("Right!");
  52.                                                 else System.out.println("Wrong!");
  53.                                                
  54.                                 }else if (secondDenom == 20) {
  55.                                         System.out.println("Who is on the " + secondDenom +" dollar bill?");
  56.                                         secondName= sc.next();
  57.                                                 if (secondName.equals("Jackson"))
  58.                                                         System.out.println("Right!");
  59.                                                 else System.out.println("Wrong!");             
  60.                                        
  61.                                 }else if (secondDenom == 50) {
  62.                                         System.out.println("Who is on the " + secondDenom +" dollar bill?");
  63.                                         secondName= sc.next();
  64.                                                 if (secondName.equals("Grant"))
  65.                                                         System.out.println("Right!");
  66.                                                 else System.out.println("Wrong!");
  67.                        
  68.                                 }else { System.out.println("Invalid choice!"); }
  69.                
  70.                 }              
  71.                
  72.                
  73.                  else System.out.println("Invalid input value!");
  74.                
  75.                        
  76.                
  77.                
  78.          
  79.                
  80.                
  81.   }
  82.  
  83. }