Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- /**
- * Write a description of class Input here.
- *
- * @author Kailey McNeal
- * @version 10-30-14
- * Prompts for and accepts names, addresses, phone numbers, and emails to be put into an address book.
- */
- import java.util.*;
- public class Input
- {
- public static void main (String[]args)
- {
- Scanner console=new Scanner(System.in);
- System.out.print("How many contacts do you want to store? ");
- int repeat=console.nextInt();
- String[] name=new String[repeat];
- String[] address=new String[repeat];
- String[] number=new String[repeat];
- String[] email=new String[repeat];
- for(int i=0; i<=repeat-1; i++)
- {
- System.out.print("");
- address[i]=console.nextLine();
- System.out.print("Name: ");
- name[i]=console.nextLine();
- System.out.print("Address: ");
- address[i]=console.nextLine();
- System.out.print("Telephone Number: ");
- number[i]=console.nextLine();
- System.out.print("Email: ");
- email[i]=console.next();
- System.out.println();
- }
- Arrays.sort(name);
- String one="Name";
- String two="Address";
- String three="Telephone Number";
- String four="Email Address";
- System.out.printf( "%-25s %-50s %-18s %-25s",one, two, three, four);
- System.out.println();
- // for(int j=0; j<=name.length+2; j++)
- // {
- // System.out.print(" ");
- // }
- // for(int j=0; j<=address.length+2; j++)
- // {
- // System.out.print(" ");
- // }
- // for(int j=0; j<=number.length+2; j++)
- // {
- // System.out.print(" ");
- // }
- // for(int j=0; j<=email.length+2; j++)
- // {
- // System.out.print(" ");
- // }
- for(int i=0; i<name.length; i++)
- {
- // for(int j=1; j<22-name.length; j++)
- // {
- // System.out.print(" ");
- // }
- System.out.printf("%-25s %-50s %-18s %-25s", name[i], address[i],number[i], email[i]);
- System.out.println();
- // for(int j=1; j<49-address.length; j++)
- // {
- // System.out.print(" ");
- // }
- // for(int j=1; j<15-number.length; j++)
- // {
- // System.out.print(" ");
- // }
- // for(int j=1; j<29-email.length; j++)
- // {
- // System.out.print(" ");
- // }
- }
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement