For beginning Java, two things 1) I got this error from my code and how and where can I fix it:  Main.java:133: error: reached end of file while parsing } ^ 1 error 2) I was told my code is too long and needs to be separate files. How can I fix this into separate Java files? 3) I need to Draw the UML diagram using MS Word or PowerPoint for the classes and implement them.  My original assignment is attached. Here's my code: import java.io.BufferedReader; import java.io.FileReader; import java.io.IOException; import java.time.LocalDate; class Person {     private String name;     private String address;     private String phoneNumber;     private String emailAddress;     public Person(String name, String address, String phoneNumber, String emailAddress) {         this.name = name;         this.address = address;         this.phoneNumber = phoneNumber;         this.emailAddress = emailAddress;     }     @Override     public String toString() {         return "Person: " + name + "\nAddress: " + address + "\nPhone Number: " + phoneNumber +                "\nEmail Address: " + emailAddress;     } } class Student extends Person {     private String classStatus;     public Student(String name, String address, String phoneNumber, String emailAddress, String classStatus) {         super(name, address, phoneNumber, emailAddress);         this.classStatus = classStatus;     }     @Override     public String toString() {         return super.toString() + "\nClass: Student" + "\nClass Status: " + classStatus;     } } class Employee extends Person {     private double salary;     private LocalDate dateHired;     public Employee(String name, String address, String phoneNumber, String emailAddress, double salary, LocalDate dateHired) {         super(name, address, phoneNumber, emailAddress);         this.salary = salary;         this.dateHired = dateHired;     }     @Override     public String toString() {         return super.toString() + "\nClass: Employee" + "\nSalary: " + salary + "\nDate Hired: " + dateHired;     } } class Faculty extends Employee {     private String officeHours;     private String discipline;     public Faculty(String name, String address, String phoneNumber, String emailAddress, double salary, LocalDate dateHired,                    String officeHours, String discipline) {         super(name, address, phoneNumber, emailAddress, salary, dateHired);         this.officeHours = officeHours;         this.discipline = discipline;     }     @Override     public String toString() {         return super.toString() + "\nClass: Faculty" + "\nOffice Hours: " + officeHours + "\nDiscipline: " + discipline;     } } class Staff extends Employee {     private String title;     public Staff(String name, String address, String phoneNumber, String emailAddress, double salary, LocalDate dateHired,                  String title) {         super(name, address, phoneNumber, emailAddress, salary, dateHired);         this.title = title;     }     @Override     public String toString() {         return super.toString() + "\nClass: Satff" + "\nTitle: " + title;     } } // test program  public class Main {     public static void main(String[] args) {         // Read data from a text file         try (BufferedReader br = new BufferedReader(new FileReader("data.txt"))) {             String line;             while ((line = br.readLine()) != null) {                 String[] data = line.split(","); switch (data[0]) {     case "Person":         if (data.length >= 5) {             Person person = new Person(data[1], data[2], data[3], data[4]);             System.out.println(person);         }         break;     case "Student":         if (data.length >= 6) {             Student student = new Student(data[1], data[2], data[3], data[4], data[5]);             System.out.println(student);         }         break;     case "Employee":         if (data.length >= 6) {             LocalDate dateHired = LocalDate.parse(data[5]);             Employee employee = new Employee(data[1], data[2], data[3], data[4], Double.parseDouble(data[5]), dateHired);             System.out.println(employee);         }         break;     case "Faculty":         if (data.length >= 8) {             LocalDate facultyDateHired = LocalDate.parse(data[6]);             Faculty faculty = new Faculty(data[1], data[2], data[3], data[4], Double.parseDouble(data[5]), facultyDateHired, data[6], data[7]);             System.out.println(faculty);         }         break;     case "Staff":         if (data.length >= 7) {             LocalDate staffDateHired = LocalDate.parse(data[5]);             Staff staff = new Staff(data[1], data[2], data[3], data[4], Double.parseDouble(data[5]), staffDateHired, data[6]);             System.out.println(staff);         }         break;     default:         System.out.println("Invalid entry");         break; }

Database System Concepts
7th Edition
ISBN:9780078022159
Author:Abraham Silberschatz Professor, Henry F. Korth, S. Sudarshan
Publisher:Abraham Silberschatz Professor, Henry F. Korth, S. Sudarshan
Chapter1: Introduction
Section: Chapter Questions
Problem 1PE
icon
Related questions
Question

For beginning Java, two things

1) I got this error from my code and how and where can I fix it: 

Main.java:133: error: reached end of file while parsing } ^ 1 error

2) I was told my code is too long and needs to be separate files. How can I fix this into separate Java files?

3) I need to Draw the UML diagram using MS Word or PowerPoint for the classes and implement them. 

My original assignment is attached.

Here's my code:

import java.io.BufferedReader;
import java.io.FileReader;
import java.io.IOException;
import java.time.LocalDate;

class Person {
    private String name;
    private String address;
    private String phoneNumber;
    private String emailAddress;

    public Person(String name, String address, String phoneNumber, String emailAddress) {
        this.name = name;
        this.address = address;
        this.phoneNumber = phoneNumber;
        this.emailAddress = emailAddress;
    }

    @Override
    public String toString() {
        return "Person: " + name + "\nAddress: " + address + "\nPhone Number: " + phoneNumber +
               "\nEmail Address: " + emailAddress;
    }
}

class Student extends Person {
    private String classStatus;

    public Student(String name, String address, String phoneNumber, String emailAddress, String classStatus) {
        super(name, address, phoneNumber, emailAddress);
        this.classStatus = classStatus;
    }

    @Override
    public String toString() {
        return super.toString() + "\nClass: Student" + "\nClass Status: " + classStatus;
    }
}

class Employee extends Person {
    private double salary;
    private LocalDate dateHired;

    public Employee(String name, String address, String phoneNumber, String emailAddress, double salary, LocalDate dateHired) {
        super(name, address, phoneNumber, emailAddress);
        this.salary = salary;
        this.dateHired = dateHired;
    }

    @Override
    public String toString() {
        return super.toString() + "\nClass: Employee" + "\nSalary: " + salary + "\nDate Hired: " + dateHired;
    }
}

class Faculty extends Employee {
    private String officeHours;
    private String discipline;

    public Faculty(String name, String address, String phoneNumber, String emailAddress, double salary, LocalDate dateHired,
                   String officeHours, String discipline) {
        super(name, address, phoneNumber, emailAddress, salary, dateHired);
        this.officeHours = officeHours;
        this.discipline = discipline;
    }

    @Override
    public String toString() {
        return super.toString() + "\nClass: Faculty" + "\nOffice Hours: " + officeHours + "\nDiscipline: " + discipline;
    }
}

class Staff extends Employee {
    private String title;

    public Staff(String name, String address, String phoneNumber, String emailAddress, double salary, LocalDate dateHired,
                 String title) {
        super(name, address, phoneNumber, emailAddress, salary, dateHired);
        this.title = title;
    }

    @Override
    public String toString() {
        return super.toString() + "\nClass: Satff" + "\nTitle: " + title;
    }
}

// test program 
public class Main {
    public static void main(String[] args) {
        // Read data from a text file
        try (BufferedReader br = new BufferedReader(new FileReader("data.txt"))) {
            String line;
            while ((line = br.readLine()) != null) {
                String[] data = line.split(",");
switch (data[0]) {
    case "Person":
        if (data.length >= 5) {
            Person person = new Person(data[1], data[2], data[3], data[4]);
            System.out.println(person);
        }
        break;
    case "Student":
        if (data.length >= 6) {
            Student student = new Student(data[1], data[2], data[3], data[4], data[5]);
            System.out.println(student);
        }
        break;
    case "Employee":
        if (data.length >= 6) {
            LocalDate dateHired = LocalDate.parse(data[5]);
            Employee employee = new Employee(data[1], data[2], data[3], data[4], Double.parseDouble(data[5]), dateHired);
            System.out.println(employee);
        }
        break;
    case "Faculty":
        if (data.length >= 8) {
            LocalDate facultyDateHired = LocalDate.parse(data[6]);
            Faculty faculty = new Faculty(data[1], data[2], data[3], data[4], Double.parseDouble(data[5]), facultyDateHired, data[6], data[7]);
            System.out.println(faculty);
        }
        break;
    case "Staff":
        if (data.length >= 7) {
            LocalDate staffDateHired = LocalDate.parse(data[5]);
            Staff staff = new Staff(data[1], data[2], data[3], data[4], Double.parseDouble(data[5]), staffDateHired, data[6]);
            System.out.println(staff);
        }
        break;
    default:
        System.out.println("Invalid entry");
        break;
}

### Java Program: Inheritance and Class Structure

The code snippet illustrates a simple Java program that demonstrates the concepts of classes, inheritance, and method overriding within the context of personal information management.

#### Code Explanation

The program is designed to create two classes: `Person` and `Student`, where the `Student` class extends the `Person` class, showcasing inheritance.

#### Classes and Members

- **Class `Person`:**
  - **Attributes:**
    - `name`: Stores the name of the person.
    - `address`: Stores the address of the person.
    - `phoneNumber`: Stores the phone number of the person.
    - `emailAddress`: Stores the email address of the person.
  - **Constructor:** Takes four parameters to initialize the attributes of the `Person` class.
  - **Method:**
    - `toString()`: An overridden method that returns a formatted string containing all the personal details.

```java
class Person {
    private String name;
    private String address;
    private String phoneNumber;
    private String emailAddress;

    public Person(String name, String address, String phoneNumber, String emailAddress) {
        this.name = name;
        this.address = address;
        this.phoneNumber = phoneNumber;
        this.emailAddress = emailAddress;
    }

    @Override
    public String toString() {
        return "Person: " + name + "\nAddress: " + address + "\nPhone Number: " + phoneNumber + "\nEmail Address: " + emailAddress;
    }
}
```

- **Class `Student`:**
  - **Attributes:**
    - `classStatus`: Represents the academic status or class level of the student.
  - **Constructor:** Inherits attributes from the `Person` class and adds `classStatus`.
  - **Method:**
    - `toString()`: An overridden method that calls `super.toString()` and appends additional student-specific information.

```java
class Student extends Person {
    private String classStatus;

    public Student(String name, String address, String phoneNumber, String emailAddress, String classStatus) {
        super(name, address, phoneNumber, emailAddress);
        this.classStatus = classStatus;
    }

    @Override
    public String toString() {
        return super.toString() + "\nClass: Student" + "\nClass Status: " + classStatus;
    }
}
```

#### Error
Transcribed Image Text:### Java Program: Inheritance and Class Structure The code snippet illustrates a simple Java program that demonstrates the concepts of classes, inheritance, and method overriding within the context of personal information management. #### Code Explanation The program is designed to create two classes: `Person` and `Student`, where the `Student` class extends the `Person` class, showcasing inheritance. #### Classes and Members - **Class `Person`:** - **Attributes:** - `name`: Stores the name of the person. - `address`: Stores the address of the person. - `phoneNumber`: Stores the phone number of the person. - `emailAddress`: Stores the email address of the person. - **Constructor:** Takes four parameters to initialize the attributes of the `Person` class. - **Method:** - `toString()`: An overridden method that returns a formatted string containing all the personal details. ```java class Person { private String name; private String address; private String phoneNumber; private String emailAddress; public Person(String name, String address, String phoneNumber, String emailAddress) { this.name = name; this.address = address; this.phoneNumber = phoneNumber; this.emailAddress = emailAddress; } @Override public String toString() { return "Person: " + name + "\nAddress: " + address + "\nPhone Number: " + phoneNumber + "\nEmail Address: " + emailAddress; } } ``` - **Class `Student`:** - **Attributes:** - `classStatus`: Represents the academic status or class level of the student. - **Constructor:** Inherits attributes from the `Person` class and adds `classStatus`. - **Method:** - `toString()`: An overridden method that calls `super.toString()` and appends additional student-specific information. ```java class Student extends Person { private String classStatus; public Student(String name, String address, String phoneNumber, String emailAddress, String classStatus) { super(name, address, phoneNumber, emailAddress); this.classStatus = classStatus; } @Override public String toString() { return super.toString() + "\nClass: Student" + "\nClass Status: " + classStatus; } } ``` #### Error
**The Person, Student, Employee, Faculty, and Staff Classes**

1) **Design a Class Structure:**
   - Create a class named `Person` and its two subclasses named `Student` and `Employee`.
   - `Employee` has two subclasses: `Faculty` and `Staff`.
   - A `Person` includes attributes such as a name, address, phone number, and email address.
   - `Student` includes a class status (e.g., freshman, sophomore, junior, or senior).
   - `Employee` includes attributes like salary (double) and date hired.
   - Use `java.time.LocalDate` for the date hired attribute.
   - `Faculty` has office hours (e.g., “Friday 3-4PM”) and discipline (e.g., “Computer Science” or “Math”).
   - `Staff` includes a title attribute.
   - Override the `toString` method in each class to display the class name and related data.
   - **Task:** Draw the UML diagram using MS Word or PowerPoint for the classes and implement them.

2) **Develop a Test Program:**
   - Create a program that generates instances of `Person`, `Student`, `Employee`, `Faculty`, and `Staff`, invoking their `toString()` methods.
   - The program should read a text file containing data for these objects, with each line representing one object.
   - Determine a format for your data that your program can parse successfully.

3) **Submission Requirements:**
   - Submit all Java files.
   - Provide the MS Word or PowerPoint file used for drawing UML diagrams.
   - Include the data file you created.

4) **Hints:**
   - Example of creating a `LocalDate` object:
     ```java
     LocalDate date = LocalDate.of(2020, 1, 8); // year, month, date
     ```

This exercise helps in understanding class hierarchies, inheritance, and practicing programming concepts in Java, including object creation and method overriding.
Transcribed Image Text:**The Person, Student, Employee, Faculty, and Staff Classes** 1) **Design a Class Structure:** - Create a class named `Person` and its two subclasses named `Student` and `Employee`. - `Employee` has two subclasses: `Faculty` and `Staff`. - A `Person` includes attributes such as a name, address, phone number, and email address. - `Student` includes a class status (e.g., freshman, sophomore, junior, or senior). - `Employee` includes attributes like salary (double) and date hired. - Use `java.time.LocalDate` for the date hired attribute. - `Faculty` has office hours (e.g., “Friday 3-4PM”) and discipline (e.g., “Computer Science” or “Math”). - `Staff` includes a title attribute. - Override the `toString` method in each class to display the class name and related data. - **Task:** Draw the UML diagram using MS Word or PowerPoint for the classes and implement them. 2) **Develop a Test Program:** - Create a program that generates instances of `Person`, `Student`, `Employee`, `Faculty`, and `Staff`, invoking their `toString()` methods. - The program should read a text file containing data for these objects, with each line representing one object. - Determine a format for your data that your program can parse successfully. 3) **Submission Requirements:** - Submit all Java files. - Provide the MS Word or PowerPoint file used for drawing UML diagrams. - Include the data file you created. 4) **Hints:** - Example of creating a `LocalDate` object: ```java LocalDate date = LocalDate.of(2020, 1, 8); // year, month, date ``` This exercise helps in understanding class hierarchies, inheritance, and practicing programming concepts in Java, including object creation and method overriding.
Expert Solution
trending now

Trending now

This is a popular solution!

steps

Step by step

Solved in 3 steps with 1 images

Blurred answer
Knowledge Booster
Data members
Learn more about
Need a deep-dive on the concept behind this application? Look no further. Learn more about this topic, computer-science and related others by exploring similar questions and additional content below.
Similar questions
  • SEE MORE QUESTIONS
Recommended textbooks for you
Database System Concepts
Database System Concepts
Computer Science
ISBN:
9780078022159
Author:
Abraham Silberschatz Professor, Henry F. Korth, S. Sudarshan
Publisher:
McGraw-Hill Education
Starting Out with Python (4th Edition)
Starting Out with Python (4th Edition)
Computer Science
ISBN:
9780134444321
Author:
Tony Gaddis
Publisher:
PEARSON
Digital Fundamentals (11th Edition)
Digital Fundamentals (11th Edition)
Computer Science
ISBN:
9780132737968
Author:
Thomas L. Floyd
Publisher:
PEARSON
C How to Program (8th Edition)
C How to Program (8th Edition)
Computer Science
ISBN:
9780133976892
Author:
Paul J. Deitel, Harvey Deitel
Publisher:
PEARSON
Database Systems: Design, Implementation, & Manag…
Database Systems: Design, Implementation, & Manag…
Computer Science
ISBN:
9781337627900
Author:
Carlos Coronel, Steven Morris
Publisher:
Cengage Learning
Programmable Logic Controllers
Programmable Logic Controllers
Computer Science
ISBN:
9780073373843
Author:
Frank D. Petruzella
Publisher:
McGraw-Hill Education