Advertisement
MasterShake79

Untitled

Mar 19th, 2019
85
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Java 4.02 KB | None | 0 0
  1. import java.util.Scanner;
  2. public class HansonJ002PA2
  3. {
  4.   public static void main(String [] args)
  5.   {
  6.     char another = ' ';// to collect additional input
  7.     String name = "";// collects users name
  8.     String addressee = "";// collects the name of the addressee
  9.     String street = "";// collects street of addressee
  10.     String cityStateZip = "";// collects cityStateZip of address
  11.     String phone = "";// collects the phone number of addressee
  12.     String family = String.format("%nFAMILY%n");// lists addressee as family
  13.     String friends = String.format("%nFRIENDS%n");// lists addressee as friend
  14.     String work = String.format("%nWORK%n");// lists addressee as work
  15.     String personal = String.format("%nPERSONAL%n");// sets address as personal
  16.     String business = String.format("%nBUSINESS%n");// sets address as business
  17.     String addressbook = String.format("%nADDRESSBOOK%n");
  18.     StringBuilder phoneFormatted;// collects the format used while inputing the phone number
  19.     int relationship = 0;// collects the input of the relationship between user and addressee
  20.     int bookType;
  21.     char correct = ' ';
  22.     Scanner input = new Scanner(System.in);
  23.    
  24.     System.out.printf("%nBegin entering addresses? \'Y\' or \'N\' ");
  25.     another = input.nextLine().charAt(0);
  26.    
  27.     if(Character.toUpperCase(another) != 'Y')
  28.     {
  29.       System.out.printf("%nExiting Program%n");
  30.     }
  31.     while(Character.toUpperCase(another) == 'Y')
  32.     {
  33.       do
  34.       {
  35.         System.out.printf("Address Book Type\n 1. Personal\n 2. Buisness\nChoose from above the address book type:");
  36.         bookType = input.nextInt();
  37.         input.nextLine();
  38.        
  39.         switch(bookType)
  40.         {
  41.           case 1: System.out.printf("%nYou entered 1. for Personal. Is this correct? 'Y' or 'N' ");
  42.           correct = input.nextLine().charAt(0);
  43.           break;
  44.          
  45.           case 2: System.out.printf("%nYou entered 2. for Business. Is this correct? 'Y' or 'N' ");
  46.           correct = input.nextLine().charAt(0);
  47.           break;
  48.          
  49.          
  50.         }
  51.         if(bookType != 1 && bookType != 2 )
  52.         {
  53.           System.out.printf("%nYou entered %d which is the wrong address book type. Try again. ", bookType);
  54.           correct = 'N';
  55.           input.nextLine();
  56.         }
  57.        
  58.       }while(Character.toUpperCase(correct) == 'N');
  59.      
  60.       do
  61.       {
  62.         System.out.printf("%nEnter your name: ");
  63.         name = input.nextLine();// Captures name of addressbook owner
  64.        
  65.         System.out.printf("%nYou entered %s. Is this correct? 'Y' or 'N': ",name);
  66.         correct = input.nextLine().charAt(0);
  67.         name += String.format(addressbook);
  68.        
  69.       }
  70.       while(Character.toUpperCase(correct) == 'N'); //Name validation
  71.      
  72.      
  73.       do
  74.       {
  75.         System.out.printf("%nEnter the name of the addressee: ");
  76.         addressee = input.nextLine();// Captures addressee name
  77.        
  78.         System.out.printf("%nYou entered %s. Is this correct? 'Y' or 'N': ",addressee);
  79.         correct = input.nextLine().charAt(0);
  80.       /*
  81.        do
  82.         {
  83.        
  84.         }while();//Addresse validation
  85.        
  86.         do
  87.         {
  88.        
  89.         }while();//Street address validation
  90.        
  91.         do
  92.         {
  93.        
  94.         }while();//City State Zip validation
  95.        
  96.         do
  97.         {
  98.        
  99.         }while();//Phone Number validation
  100.        
  101.         do
  102.         {
  103.         switch(relationship)
  104.         {
  105.        
  106.         }
  107.         }while();//Relationship validation
  108.        
  109.         switch(relationship)
  110.         {
  111.        
  112.         }
  113.         }while();
  114.        
  115.         switch(bookType)
  116.         {
  117.        
  118.         }//Print addressbook as personal or business
  119.         */
  120.        
  121.         System.out.printf("%nWant to create another address book? \'Y\' or \'N\' ");
  122.         another = input.nextLine().charAt(0);
  123.      
  124.     }while(Character.toUpperCase(correct) == 'Y');
  125.     }
  126.   }//END main()
  127. }//END APPLICATION CLASS HansonJ002PA2
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement