Question

In: Computer Science

I am having problems with : If 6 is selected, then you will get an employee...

I am having problems with :

If 6 is selected, then you will get an employee pay amount from the user. This will be a double. Only allow them to enter one pay amount and then display the main menu again.

AND:

if 2 is selected you will promt the user for a grade (double) from 0-100. Only allow them to enter one grade and then display the main menu again

The project:

Create a project called P03. Inside of P03 you’re going to have four classes: 1) EntrySystem.java...

(3 bookmarks)

Create a project called P03. Inside of P03 you’re going to have four classes:
1) EntrySystem.java (which will contain your main method)

2) Person.java which will be your super class will have the following properties:
first name (string)
last name (string)
id number (string)
phone (string)
street address (string)
city (string)
state (string)
zip (string)

3) Student.java will inherit from Person and will have the following additional properties:
major (string)
grades (Arraylist of doubles)
advisor (string)

Student will also have a method called displayStudent() which will display all of the students information as well as their GPA in a neatly formatted way

. 4) Employee.java will inherit from Person and will have the following additional properties:
department (string)
supervisor (string)
paychecks (ArrayList of doubles)

Employee will also have a method called displayEmployee() which will display all of the employees information as well as their pay average and pay total in a neatly formatted way. You can also add and use the HelperClass.java.
You'll create two interfaces:
PayrollInterface.java with the following methods:
AddCheckAmount(double check)
GetPayTotal()
GetPayAverage()

GradesInterface.java with the following methods:
AddNumericalGrade(double grade)
CalculateGPA()

you will use Student to create an ArrayList of Student Java Objects called students, and Employee to create an ArrayList of Employee Java Objects called employees.

In EntrySystem.java you’ll have a menu with the following options:
1) Add a Student
2) Add a Student Grade
3) View All Students
4) Clear all Students
5) Add an Employee
6) Add an Employee Pay Amount
7) View All Employees
8) Clear All Employees
9) Exit
If 1 is selected,you will prompt the user for each field of the Student class to enter. You will validate strings to make sure they are not empty. You will validate ints and doubles to make sure they are proper ints and doubles. You will then add the Student Object to an ArrayList called students, returning the user back to the menu. Feel free to use the Helper Class we've been working with.

HELP
If 2 is selected you will promt the user for a grade (double) from 0-100. Only allow them to enter one grade and then display the main menu again.

If 3 is selected, you will display the list of students in a neatly formatted way by looping through students and calling displayStudent() for each. If there are no students entered, then tell the user this.

If 4 is selected, you will clear the students ArrayList.

If 5 is selected, then you will prompt the user for each field to enter for the Employee class. You will validate strings to make sure they are not empty. You will validate doubles to make sure they are proper doubles.

HELP
If 6 is selected, then you will get an employee pay amount from the user. This will be a double. Only allow them to enter one pay amount and then display the main menu again.

If 7 is selected, you will display the list of employees in a neatly formatted way calling displayEmployee() for each. If there are no employees, then tell the user this.

If 8 is selected, you will clear the employees ArrayList.

When 9 is selected, you will exit the program.

HELP PLEASE

Solutions

Expert Solution

/********************Person.java************************/

package P03;

public class Person {

   /**
   * fields
   */
   private String firstName;
   private String lastName;
   private String idNumber;
   private String phoneNumber;
   private String streetAddress;
   private String city;
   private String state;
   private String zip;
   /**
   *
   * @param firstName
   * @param lastName
   * @param idNumber
   * @param phoneNumber
   * @param streetAddress
   * @param city
   * @param state
   * @param zip
   */
   public Person(String firstName, String lastName, String idNumber, String phoneNumber, String streetAddress,
           String city, String state, String zip) {
       super();
       this.firstName = firstName;
       this.lastName = lastName;
       this.idNumber = idNumber;
       this.phoneNumber = phoneNumber;
       this.streetAddress = streetAddress;
       this.city = city;
       this.state = state;
       this.zip = zip;
   }
   //getter and setter
   public String getFirstName() {
       return firstName;
   }
   public String getLastName() {
       return lastName;
   }
   public String getIdNumber() {
       return idNumber;
   }
   public String getPhoneNumber() {
       return phoneNumber;
   }
   public String getStreetAddress() {
       return streetAddress;
   }
   public String getCity() {
       return city;
   }
   public String getState() {
       return state;
   }
   public String getZip() {
       return zip;
   }
  
  
}
/***********************************Student.java******************************/

package P03;

import java.util.ArrayList;

public class Student extends Person implements GradesInterface{
   /**
   * fileds
   */
   private String major;
   private ArrayList<Double> grades = new ArrayList<>();
   private String advisor;
   /**
   *
   * @param firstName
   * @param lastName
   * @param idNumber
   * @param phoneNumber
   * @param streetAddress
   * @param city
   * @param state
   * @param zip
   * @param major
   * @param advisor
   */
   public Student(String firstName, String lastName, String idNumber, String phoneNumber, String streetAddress,
           String city, String state, String zip, String major, String advisor) {
       super(firstName, lastName, idNumber, phoneNumber, streetAddress, city, state, zip);
       this.major = major;
       this.advisor = advisor;
   }
   //getter and setter
   public String getMajor() {
       return major;
   }
   public ArrayList<Double> getGrades() {
       return grades;
   }
   public String getAdvisor() {
       return advisor;
   }
  
   public void setGrades(ArrayList<Double> grades) {
       this.grades = grades;
   }
   @Override
   public String toString() {
       return this.getClass().getSimpleName()+" "+ getFirstName()+ " "+ getLastName() + " "+ getIdNumber() + " has "+calculateGPA();
   }
   @Override
   public void AddNumericalGrade(double grade) {
  
       grades.add(grade);
   }
   @Override
   public double calculateGPA() {
       double gpa = 0;
       for(int i=0;i<grades.size();i++) {
           gpa = gpa+ grades.get(i).doubleValue();
       }
       gpa = gpa/grades.size();
       return gpa;
   }

  
}
/**********************************Employee.java*******************************/

package P03;

import java.util.ArrayList;

public class Employee extends Person implements PayrollInterface {

   //fields
   private String department;
   private String supervisor;
   private ArrayList<Double> paychecks = new ArrayList<>();

   /**
   *
   * @param firstName
   * @param lastName
   * @param idNumber
   * @param phoneNumber
   * @param streetAddress
   * @param city
   * @param state
   * @param zip
   * @param department
   * @param supervisor
   */
   public Employee(String firstName, String lastName, String idNumber, String phoneNumber, String streetAddress,
           String city, String state, String zip, String department, String supervisor) {
       super(firstName, lastName, idNumber, phoneNumber, streetAddress, city, state, zip);
       this.department = department;
       this.supervisor = supervisor;
   }

   //getter and setter
   public String getDepartment() {
       return department;
   }

   public String getSupervisor() {
       return supervisor;
   }

   public ArrayList<Double> getPaychecks() {
       return paychecks;
   }

   @Override
   public String toString() {
       return this.getClass().getSimpleName()+" "+ getFirstName()+ " "+ getLastName() + " "+ getIdNumber() + " has "+ GetPayTotal();
   }

   @Override
   public void AddCheckAmount(double check) {

       paychecks.add(check);
   }

   @Override
   public double GetPayTotal() {

       double payTotal = 0;
       for (int i = 0; i < paychecks.size(); i++) {
           payTotal = payTotal + paychecks.get(i);
       }
       return payTotal;
   }

   @Override
   public double GetPayAverage() {

       return GetPayTotal() / paychecks.size();

   }

}
/***********************************PayrollInterface.java*************************8/

package P03;

public interface PayrollInterface {

   public void AddCheckAmount(double check);
   public double GetPayTotal();
   public double GetPayAverage();
}
/************************GradesInterface.java****************************/

package P03;

public interface GradesInterface {

   public void AddNumericalGrade(double grade);
   public double calculateGPA();
}
/*******************************EntrySystem.java******************************/

package P03;

import java.util.ArrayList;
import java.util.Scanner;

public class EntrySystem {

   public static void main(String[] args) {

       ArrayList<Student> students = new ArrayList<>();
       ArrayList<Employee> employees = new ArrayList<>();
       Scanner scan = new Scanner(System.in);
       Student student = null;
       Employee employee = null;
       int menu;
       do {

           System.out.println("MENU: \n" + "\t1) Add a Student\r\n" + "   2) Add a Student Grade\r\n"
                   + "   3) View All Students\r\n" + "   4) Clear all Students\r\n" + "   5) Add an Employee\r\n"
                   + "   6) Add an Employee Pay Amount\r\n" + "   7) View All Employees\r\n"
                   + "   8) Clear All Employees\r\n" + "   9) Exit");
           menu = scan.nextInt();
           switch (menu) {
           case 1:
               System.out.println("Enter the first name of the student: ");
               String firstName = scan.next();
               System.out.println("Enter the last name of the student: ");
               String lastName = scan.next();
               System.out.println("Enter the id number of the student: ");
               String idNumber = scan.next();
               System.out.println("Enter the phone number of the student: ");
               String phoneNumber = scan.next();
               System.out.println("Enter the street Address of the student: ");
               String streetAddress = scan.next();
               System.out.println("Enter the city of the student: ");
               String city = scan.next();
               System.out.println("Enter the state of the student: ");
               String state = scan.next();
               System.out.println("Enter the zip code :");
               String zip = scan.next();
               System.out.println("Enter the major of the student: ");
               String major = scan.next();
               System.out.println("Enter the advisor of the student: ");
               String advisor = scan.next();
               student = new Student(firstName, lastName, idNumber, phoneNumber, streetAddress, city, state, zip,
                       major, advisor);
               students.add(student);
               break;
           case 2:
               System.out.println("Enter the student grades: ");
               double grade = scan.nextDouble();
               student.AddNumericalGrade(grade);
               break;

           case 3:

               for (int i = 0; i < students.size(); i++) {
                   System.out.println(students.get(i).toString());
               }
               break;

           case 4:
               students.clear();
               break;

           case 5:
               System.out.println("Enter the first name of the Employee: ");
               String firstNameEmployee = scan.next();
               System.out.println("Enter the last name of the Employee: ");
               String lastNameEmployee = scan.next();
               System.out.println("Enter the id number of the Employee: ");
               String idNumberEmployee = scan.next();
               System.out.println("Enter the phone number of the Employee: ");
               String phoneNumberEmployee = scan.next();
               System.out.println("Enter the street Address of the Employee: ");
               String streetAddressEmployee = scan.next();
               System.out.println("Enter the city of the Employee: ");
               String cityEmployee = scan.next();
               System.out.println("Enter the state of the Employee: ");
               String stateEmployee = scan.next();
               System.out.println("Enter the zip code :");
               String zipEmployee = scan.next();
               System.out.println("Enter the deparment of the Employee: ");
               String deparmentEmployee = scan.next();
               System.out.println("Enter the supervisor of the Employee: ");
               String supervisorEmployee = scan.next();
               employee = new Employee(firstNameEmployee, lastNameEmployee, idNumberEmployee, phoneNumberEmployee,
                       streetAddressEmployee, cityEmployee, stateEmployee, zipEmployee, deparmentEmployee,
                       supervisorEmployee);
               employees.add(employee);
               break;

           case 6:
               System.out.println("Enter the Employee's pay check: ");
               double check = scan.nextDouble();
               employee.AddCheckAmount(check);
                      
               break;

           case 7:
               for (int i = 0; i < employees.size(); i++) {

                   System.out.println(employees.get(i).toString());
               }
               break;

           case 8:
                       employees.clear();
               break;

           case 9:
                   System.exit(0);
               break;

           default:
               System.out.println("Invalid choice!!!!");
               break;
           }
       } while (menu != 9);
   }

}
/****************************output*********************************/

MENU:
   1) Add a Student
   2) Add a Student Grade
   3) View All Students
   4) Clear all Students
   5) Add an Employee
   6) Add an Employee Pay Amount
   7) View All Employees
   8) Clear All Employees
   9) Exit
1
Enter the first name of the student:
jugal
Enter the last name of the student:
kishor
Enter the id number of the student:
abc2334
Enter the phone number of the student:
989784789
Enter the street Address of the student:
abcd
Enter the city of the student:
jaipur
Enter the state of the student:
raj
Enter the zip code :
787878
Enter the major of the student:
cse
Enter the advisor of the student:
ms
MENU:
   1) Add a Student
   2) Add a Student Grade
   3) View All Students
   4) Clear all Students
   5) Add an Employee
   6) Add an Employee Pay Amount
   7) View All Employees
   8) Clear All Employees
   9) Exit
2
Enter the student grades:
89
MENU:
   1) Add a Student
   2) Add a Student Grade
   3) View All Students
   4) Clear all Students
   5) Add an Employee
   6) Add an Employee Pay Amount
   7) View All Employees
   8) Clear All Employees
   9) Exit
3
Student jugal kishor abc2334 has 89.0
MENU:
   1) Add a Student
   2) Add a Student Grade
   3) View All Students
   4) Clear all Students
   5) Add an Employee
   6) Add an Employee Pay Amount
   7) View All Employees
   8) Clear All Employees
   9) Exit
4
MENU:
   1) Add a Student
   2) Add a Student Grade
   3) View All Students
   4) Clear all Students
   5) Add an Employee
   6) Add an Employee Pay Amount
   7) View All Employees
   8) Clear All Employees
   9) Exit
3
MENU:
   1) Add a Student
   2) Add a Student Grade
   3) View All Students
   4) Clear all Students
   5) Add an Employee
   6) Add an Employee Pay Amount
   7) View All Employees
   8) Clear All Employees
   9) Exit
5
Enter the first name of the Employee:
jks
Enter the last name of the Employee:
kish
Enter the id number of the Employee:
er8807
Enter the phone number of the Employee:
9837498
Enter the street Address of the Employee:
efgdg
Enter the city of the Employee:
delhi
Enter the state of the Employee:
delhi
Enter the zip code :
398789
Enter the deparment of the Employee:
IT
Enter the supervisor of the Employee:
jks
MENU:
   1) Add a Student
   2) Add a Student Grade
   3) View All Students
   4) Clear all Students
   5) Add an Employee
   6) Add an Employee Pay Amount
   7) View All Employees
   8) Clear All Employees
   9) Exit
6
Enter the Employee's pay check:
73647
MENU:
   1) Add a Student
   2) Add a Student Grade
   3) View All Students
   4) Clear all Students
   5) Add an Employee
   6) Add an Employee Pay Amount
   7) View All Employees
   8) Clear All Employees
   9) Exit
6
Enter the Employee's pay check:
8478
MENU:
   1) Add a Student
   2) Add a Student Grade
   3) View All Students
   4) Clear all Students
   5) Add an Employee
   6) Add an Employee Pay Amount
   7) View All Employees
   8) Clear All Employees
   9) Exit
7
Employee jks kish er8807 has 82125.0
MENU:
   1) Add a Student
   2) Add a Student Grade
   3) View All Students
   4) Clear all Students
   5) Add an Employee
   6) Add an Employee Pay Amount
   7) View All Employees
   8) Clear All Employees
   9) Exit
8
MENU:
   1) Add a Student
   2) Add a Student Grade
   3) View All Students
   4) Clear all Students
   5) Add an Employee
   6) Add an Employee Pay Amount
   7) View All Employees
   8) Clear All Employees
   9) Exit
7
MENU:
   1) Add a Student
   2) Add a Student Grade
   3) View All Students
   4) Clear all Students
   5) Add an Employee
   6) Add an Employee Pay Amount
   7) View All Employees
   8) Clear All Employees
   9) Exit
9

Thanks a lot, Please let me know if you have any problem...........


Related Solutions

I am working on an accounting assignment and am having problems. Firstly, 1.I need to journalize...
I am working on an accounting assignment and am having problems. Firstly, 1.I need to journalize these entries and post the closing entries 2. i need to prepare Dalhanis multi-step income statement and statement of owners equity for August 2010 3. i need to prepare the blance sheet at august 31,2010 4. i need to prepare a post-closing trial balance at august 31,2010 DALHANI makes all credit sales on terms 2/10 n/30 and uses the Perpetual Inventory System Aug 1...
I am working on an accounting assignment and am having problems. Firstly, 1.I need to journalize...
I am working on an accounting assignment and am having problems. Firstly, 1.I need to journalize these entries and post the closing entries 2. i need to prepare Dalhanis multi-step income statement and statement of owners equity for August 2010 3. i need to prepare the blance sheet at august 31,2010 4. i need to prepare a post-closing trial balance at august 31,2010 DALHANI makes all credit sales on terms 2/10 n/30 and uses the Perpetual Inventory System Aug 1...
I am having problems getting the second button part of this to work. this is for...
I am having problems getting the second button part of this to work. this is for visual basic using visual studio 2017. Please help. Create an application named You Do It 4 and save it in the VB2017\Chap07 folder. Add two labels and two buttons to the form. Create a class-level variable named strLetters and initialize it to the first 10 uppercase letters of the alphabet (the letters A through J). The first button’s Click event procedure should use the...
I am stumped on these problems and homework question, please could I get the answers to...
I am stumped on these problems and homework question, please could I get the answers to the questions below from an expert. Thank you 5). Suppose that two population proportions are being compared to test weather there is any difference between them. Assume that the test statistic has been calculated to be z= 2.21. Find the p-value for this situation?   a). p-value = 0.4864 b). p-value = 0.0272 c). p-value = 0.9728 d). p-value = 0.0136. 8). If you are...
I have a project due and am having problems compiling a program: The only program I...
I have a project due and am having problems compiling a program: The only program I have written is check.c everything else is given and correct. Can you modify check.c to simply print out the chessboard, in other words, to get it to compile by any means thank you. The only thing you have to modify again is check.c nothing else. Just get it to print something thanks. program chess.c #include #include #include "chess.h" void get_valid_move(int mover) { int x_from,...
I am having problems trying to figure out what information to pull to prepare budgets
I am having problems trying to figure out what information to pull to prepare budgets
I am having a trouble with a python program. I am to create a program that...
I am having a trouble with a python program. I am to create a program that calculates the estimated hours and mintutes. Here is my code. #!/usr/bin/env python3 #Arrival Date/Time Estimator # # from datetime import datetime import locale mph = 0 miles = 0 def get_departure_time():     while True:         date_str = input("Estimated time of departure (HH:MM AM/PM): ")         try:             depart_time = datetime.strptime(date_str, "%H:%M %p")         except ValueError:             print("Invalid date format. Try again.")             continue        ...
Helou from Croatia(Sorry for my bad english). I am having problems with fluid mechanichs. I wonder...
Helou from Croatia(Sorry for my bad english). I am having problems with fluid mechanichs. I wonder if maybe someone can help me with strategy of solving this type of tasks and maybe write and explain all of the formulas that I need for solving all of the types for fluid statics and dynamics? Thank you.
Hi I am having the following problem. At the moment I am trying to create a...
Hi I am having the following problem. At the moment I am trying to create a bode plot for the following function. G(s)=(Ks+3)/((s+2)(s+3)) Note: Not K(s+2)! I then want to plot multiple bode plots for various values of K. Eg. 1,2,3, etc. I am having two separate issues. 1. How do I define the TF with a constant K in the location required (a multiple of s in the numerator) 2. How do I create multiple bode plots for values...
Hi, I am doing an experiment that is called NaBH4 reduction of acetophenone. I am having...
Hi, I am doing an experiment that is called NaBH4 reduction of acetophenone. I am having trouble understand the techinque/wording when using a sep funnel. These are some of the procedures below: 1. Pour the mixture into a separatory funnel and add 20 mL of ice water. Rinse the beaker with additional ice water (5 mL) and add the rinsing to the separatory funnel. Rinise the beaker with ether (2 X 15 mL), adding the ether to the separatory funnel....
ADVERTISEMENT
ADVERTISEMENT
ADVERTISEMENT