Advertisement
mcnealk

Final Project--Address Book

Nov 5th, 2014
162
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 2.70 KB | None | 0 0
  1.  
  2. /**
  3. * Write a description of class Input here.
  4. *
  5. * @author Kailey McNeal
  6. * @version 10-30-14
  7. * Prompts for and accepts names, addresses, phone numbers, and emails to be put into an address book.
  8. */
  9.  
  10. import java.util.*;
  11. public class Input
  12. {
  13. public static void main (String[]args)
  14. {
  15.  
  16. Scanner console=new Scanner(System.in);
  17. System.out.print("How many contacts do you want to store? ");
  18. int repeat=console.nextInt();
  19. String[] name=new String[repeat];
  20. String[] address=new String[repeat];
  21. String[] number=new String[repeat];
  22. String[] email=new String[repeat];
  23. for(int i=0; i<=repeat-1; i++)
  24. {
  25. System.out.print("");
  26. address[i]=console.nextLine();
  27. System.out.print("Name: ");
  28. name[i]=console.nextLine();
  29. System.out.print("Address: ");
  30. address[i]=console.nextLine();
  31. System.out.print("Telephone Number: ");
  32. number[i]=console.nextLine();
  33. System.out.print("Email: ");
  34. email[i]=console.next();
  35. System.out.println();
  36. }
  37. Arrays.sort(name);
  38. String one="Name";
  39. String two="Address";
  40. String three="Telephone Number";
  41. String four="Email Address";
  42. System.out.printf( "%-25s %-50s %-18s %-25s",one, two, three, four);
  43. System.out.println();
  44. // for(int j=0; j<=name.length+2; j++)
  45. // {
  46. // System.out.print(" ");
  47. // }
  48.  
  49. // for(int j=0; j<=address.length+2; j++)
  50. // {
  51. // System.out.print(" ");
  52. // }
  53.  
  54. // for(int j=0; j<=number.length+2; j++)
  55. // {
  56. // System.out.print(" ");
  57. // }
  58.  
  59. // for(int j=0; j<=email.length+2; j++)
  60. // {
  61. // System.out.print(" ");
  62. // }
  63.  
  64. for(int i=0; i<name.length; i++)
  65. {
  66. // for(int j=1; j<22-name.length; j++)
  67. // {
  68. // System.out.print(" ");
  69. // }
  70. System.out.printf("%-25s %-50s %-18s %-25s", name[i], address[i],number[i], email[i]);
  71. System.out.println();
  72. // for(int j=1; j<49-address.length; j++)
  73. // {
  74. // System.out.print(" ");
  75. // }
  76.  
  77. // for(int j=1; j<15-number.length; j++)
  78. // {
  79. // System.out.print(" ");
  80. // }
  81.  
  82. // for(int j=1; j<29-email.length; j++)
  83. // {
  84. // System.out.print(" ");
  85. // }
  86.  
  87. }
  88. }
  89. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement