Design and implement an application name the driver class Pa
Solution
 /**
 *
 * The java class Person that represetnts
 * the object of person*/
 //Person.java
 public class Person {
   private String firstName;
    private String lastName;
    private int zipcode;
   
    public Person() {
        firstName=\"\";
        lastName=\"\";
        zipcode=0;
    }
   
    //Mutator/setter methods
    public void setFirstName(String firstName){
        this.firstName=firstName;
    }
    public void setLastName(String lastName){
        this.lastName=lastName;
    }
    public void setZipCode(int zipcode){
        this.zipcode=zipcode;
    }
   
    //Accessor/getter methods
    public String getFirstName(){
        return firstName;
    }
    public String getLastName(){
        return lastName;
    }
    public int getZipCode(){
        return zipcode;
    }
   
    //Returns string description of the Person object
    @Override
    public String toString() {      
        return String.format(\"%-15s%-15s%-10d\", firstName,lastName,zipcode);
    }
       
 }
----------------------------------------------------------------------------------------------------------------------------
/**
 * the java program that reads a text file
 * called activity1.txt and stores the values in
 * Person class and print the person object
 * data to console.
 * */
 //Part3.java
 import java.io.File;
 import java.io.FileNotFoundException;
 import java.util.Scanner;
 public class Part3
 {
    public static void main(String[] args)
    {  
        String fileName=\"activity1.txt\";      
        Scanner filescanner=null;
       
        //Create an array of type Person class
        Person[] persons=new Person[25];
        int index=0;
       
        try
        {
            //Create a Scanner class object
            filescanner=new Scanner(new File(fileName));      
            String line=\"\";      
            //read text data from file
            while(filescanner.hasNextLine())
            {
                //read line from file
                line=filescanner.nextLine();
               
                //split the line using space delimiter
                String data[]=line.split(\" \");
                String firstName=data[0];
                String lastName=data[1];
                int zipcode=Integer.parseInt(data[2]);
               
                //create a person object
                persons[index]=new Person();
                //Set first name, last name and zip code
                persons[index].setFirstName(firstName);
                persons[index].setLastName(lastName);              
                persons[index].setZipCode(zipcode);
               
                index=index+1;
            }          
            System.out.printf(\"%-15s%-15s%-15s\ \",\"FirstName\",\"LastName\",\"Zipcode\");
             System.out.printf(\"-------------------------------------\ \");
       
            //print persons objects to console
            for (int i = 0; i < persons.length; i++)
            {
                System.out.println(persons[i]);
            }
        }
        catch (FileNotFoundException e)
        {
            System.out.println(e.getMessage());
        }  
    }  
 }//end of the Part3 class
----------------------------------------------------------------------------------------------------------------------------
activity1.txt
Hilton Barile 12345
 Bernardine Ewart 12346
 Shellie Przybyla 12347
 Odell Perlmutter 12348
 Bob Ewell 12335
 Gillian Ledford 12367
 Derick Ramsburg 16745
 Monet Caudell 18945
 Amalia Bakken 23456
 Bernardo Macgillivray 45676
 Erick Froehlich 45454
 Lakia Velasques 34654
 Mathew Zahn 66767
 Jutta Levey 68676
 Brent Fallis 67856
 Carri Laflamme 53435
 Millard Teegarden 34543
 Diane Hardisty 78678
 Vi Weidemann 78645
 Iona Kitchin 32424
 Sheri Yuan 23245
 Franchesca Goettl 45354
 Audry Hanes 54353
 Evangelina Dansby 54354
 Leatha Minear 87868
----------------------------------------------------------------------------------------------------------------------------
sample output:
FirstName      LastName       Zipcode      
 -------------------------------------------------
 Hilton         Barile         12345   
 Bernardine     Ewart          12346   
 Shellie        Przybyla       12347   
 Odell          Perlmutter     12348   
 Bob            Ewell          12335   
 Gillian        Ledford        12367   
 Derick         Ramsburg       16745   
 Monet          Caudell        18945   
 Amalia         Bakken         23456   
 Bernardo       Macgillivray   45676   
 Erick          Froehlich      45454   
 Lakia          Velasques      34654   
 Mathew         Zahn           66767   
 Jutta          Levey          68676   
 Brent          Fallis         67856   
 Carri          Laflamme       53435   
 Millard        Teegarden      34543   
 Diane          Hardisty       78678   
 Vi             Weidemann      78645   
 Iona           Kitchin        32424   
 Sheri          Yuan           23245   
 Franchesca     Goettl         45354   
 Audry          Hanes          54353   
 Evangelina     Dansby         54354   
 Leatha         Minear         87868   




