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; }

EBK JAVA PROGRAMMING
9th Edition
ISBN:9781337671385
Author:FARRELL
Publisher:FARRELL
Chapter5: Making Decisions
Section: Chapter Questions
Problem 8PE
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;
}

ņ ▶ Run Ⓒ Debug
Main.java data.txt ⠀
1 import java.io.Buffered Reader;
2 import java.io.FileReader;
3 import java.io.IOException;
4 import java.time. LocalDate;
5
6- class Person {
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24 }
25
29-
30
31
32
33
34
35-
36
37
38 }
}
26- class Student extends Person {
27
private String classStatus;
28
1 error
private String name;
private String address;
private String phoneNumber;
private String emailAddress;
}
Stop
public Person (String name, String address, String phoneNumber, String emailAddress) {
this.name = name;
this.address - address;
Share H Saved {} Beautify ±
@Override
public String toString() {
return "Person: " + name + "\nAddress: " + address + "\nPhone Number: " + phoneNumber +
| | "\nEmail Address: + emailAddress;
}
}
this.phoneNumber = phoneNumber;
this.emailAddress = emailAddress;
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;
Compilation failed due to following error(s).
Main.java:133: error: reached end of file while parsing
input
stderr
Language Java
Transcribed Image Text:ņ ▶ Run Ⓒ Debug Main.java data.txt ⠀ 1 import java.io.Buffered Reader; 2 import java.io.FileReader; 3 import java.io.IOException; 4 import java.time. LocalDate; 5 6- class Person { 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 } 25 29- 30 31 32 33 34 35- 36 37 38 } } 26- class Student extends Person { 27 private String classStatus; 28 1 error private String name; private String address; private String phoneNumber; private String emailAddress; } Stop public Person (String name, String address, String phoneNumber, String emailAddress) { this.name = name; this.address - address; Share H Saved {} Beautify ± @Override public String toString() { return "Person: " + name + "\nAddress: " + address + "\nPhone Number: " + phoneNumber + | | "\nEmail Address: + emailAddress; } } this.phoneNumber = phoneNumber; this.emailAddress = emailAddress; 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; Compilation failed due to following error(s). Main.java:133: error: reached end of file while parsing input stderr Language Java
The Person, Student, Employee, Faculty, and Staff classes
1) Design a class named Person and its two subclasses named Student and Employee.
Make Faculty and Staff subclasses of Employee. A person has a name,
address, phone number, and e-mail address. A student has a class status (freshman,
sophomore, junior, or senior). An employee
salary (double), and date hired. Use the java.time. LocalDate class to create an object for date hired. A faculty
member has office hours (example: "Friday 3-4PM") and discipline (like "Computer Science" or "Math"). A staff
member has a title. Override the to String method in each class to display the class name and all related data.
Draw the UML diagram using MS Word or PowerPoint for the classes and implement them.
2) Write a test program that creates a Person, Student, Employee, Faculty, and Staff, and invokes
their to String() methods. Your program needs to read a text file containing data for these objects. One line for each
object. You need to figure out the format of your data as long as your program can read it.
3) Submit the following:
•
•
All Java files
The MS Word or PowerPoint file drawing UML diagrams
The data file you create
4) Hints:
Example how to create a LocalDate object:
LocalDate date = LocalDate.of(2020, 1, 8); // year, month, date
Transcribed Image Text:The Person, Student, Employee, Faculty, and Staff classes 1) Design a class named Person and its two subclasses named Student and Employee. Make Faculty and Staff subclasses of Employee. A person has a name, address, phone number, and e-mail address. A student has a class status (freshman, sophomore, junior, or senior). An employee salary (double), and date hired. Use the java.time. LocalDate class to create an object for date hired. A faculty member has office hours (example: "Friday 3-4PM") and discipline (like "Computer Science" or "Math"). A staff member has a title. Override the to String method in each class to display the class name and all related data. Draw the UML diagram using MS Word or PowerPoint for the classes and implement them. 2) Write a test program that creates a Person, Student, Employee, Faculty, and Staff, and invokes their to String() methods. Your program needs to read a text file containing data for these objects. One line for each object. You need to figure out the format of your data as long as your program can read it. 3) Submit the following: • • All Java files The MS Word or PowerPoint file drawing UML diagrams The data file you create 4) Hints: Example how to create a LocalDate object: LocalDate date = LocalDate.of(2020, 1, 8); // year, month, date
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
EBK JAVA PROGRAMMING
EBK JAVA PROGRAMMING
Computer Science
ISBN:
9781337671385
Author:
FARRELL
Publisher:
CENGAGE LEARNING - CONSIGNMENT
Programming Logic & Design Comprehensive
Programming Logic & Design Comprehensive
Computer Science
ISBN:
9781337669405
Author:
FARRELL
Publisher:
Cengage