Question

(PLEASE UPLOAD ALL PARTS TO THE QUESTION) (IE: PSEUDO CODE AND JAVA CODE TOGETHER NOT ONE...

(PLEASE UPLOAD ALL PARTS TO THE QUESTION) (IE: PSEUDO CODE AND JAVA CODE TOGETHER NOT ONE OR THE OTHER)

Design an Employee class that fields for the following pieces of information:

1) Employee name

2) Employee number

Next design a class named ProductionWorker that extends the Employee class.

The ProductionWorker class should have fields to hold the following information:

1) Shift number (an integer, such as 1, 2, or 3)

2)Hourly pay

The workday is divided into two shifts day and night. The shift field will hold an integer value representing the shift that the employee works. The day shift is "shift 1" and the night shift is "shift 2". Design the appropriate accessor and mutator methods for each class.

Once you have designed the classes, design a program that creates an object of the ProductionWorker class and prompts the user to enter data for each of the object's fields. Store data in the object and then the object's accessor methods to retrieve it and display it on screen.

(PLEASE UPLOAD ALL PARTS TO THE QUESTION) (IE: PSEUDO CODE AND JAVA CODE TOGETHER NOT ONE OR THE OTHER)

Your solution should include:

  1. Flowchart

  2. Pseudo-code (Gaddis Pseudo-Code)

  3. Program Coded (Java Code that is converted from the Pseudo-Code)

  4. Program Output

Problem Statement

You should use either inheritance or polymorphism to obtain results in your program.  

Each set of data should be displayed in following form:

Name: John Smith
Employee Number: 12345
Shift: Day
Hourly Pay Rate: $1500

(PLEASE UPLOAD ALL PARTS TO THE QUESTION) (IE: PSEUDO CODE AND JAVA CODE TOGETHER NOT ONE OR THE OTHER)

(If you have the introduction to computer programming book, this problem can be found on page 454, #4 in the gaddis text)

0 0
Add a comment Improve this question Transcribed image text
Answer #1

FLOW CHART

///////////////////////////////Pseudo Code//////////////////////////////////////////////

Class Employee
    Private String EmployeeName
    Private int EmployeeNumber
    
    Public Function setEmployeeName(String EmployeeName)
        assign Employee name
    End Function
    
    Public Function setEmployeeNumber(int EmployeeNumber) 
         assign Employee number 
    End Function

    Public Function getEmployeeName()
         return Employee name
    End Function

   Public Function getEmployeeNumber()
        return Employee number
   End Function

End Class

//Similarily for ProductionWorker
Class ProductionWorker
     Private int shiftNumber
     Private int hourlypay
     Public Function setShiftNumber(int shiftnumber) 
        assign shift number
     End Function

     Public Function sethourlypay(int hourlypay)
        assign hourly pay
     End Function

     Public Function getShiftNumber()
        return shift number
     End Function

    Public Function gethourlypay()
       return hourlypay
    End Function
End Class

//User Class
similar to above classes but here object is created as shown
Declare ProductionWorker object
Set object = New ProductionWorker()

////////////////////JAVA CODE TO IMPLEMENT ABOVE PSEUDO CODE/////////////////////////////

import java.util.Scanner;
class Employee{                       //Employee class with atributes employeeName and employeeNumber
  
private String employeeName;
   private int employeeNumber;
  
   //accessors
  
public String getEmployeeName(){
       return this.employeeName;       // this keyword holds the reference of current object
   }
  
   public int getEmployeeNumber(){
       return this.employeeNumber;
   }
  
   //Mutators
  
public void setEmployeeName(String employeeName){
       this.employeeName=employeeName;
   }
  
   public void setEmployeeNumber(int employeeNumber){
       this.employeeNumber=employeeNumber;
   }
}
class ProductionWorker extends Employee{       //extends keyword is used for inheritence class ProductionWorker inherits Employee class
   int shiftNumber;
   int hourlyPay;
  
   //accessors
  
public int getShiftNumber(){
       return this.shiftNumber;
   }
  
   public int getHourlyPay(){
       return this.hourlyPay;
   }
  
   //Mutators
  
public void setShiftNumber(int shiftNumber){
       this.shiftNumber=shiftNumber;
   }
  
   public void setHourlyPay(int hourlyPay){
       this.hourlyPay=hourlyPay;
   }
}

//Designing the user class which uses above classes and its object is created

class User{
   public static void main(String arg[]){
       ProductionWorker object = new ProductionWorker();
      
       Scanner scan = new Scanner(System.in);      //Scanner object for scanning data from user
      
  
   System.out.println("INPUT");
      
       System.out.print("Enter employee Name ");
       String employeeName=scan.nextLine();       //nextLine() is used to read string with space
      

       System.out.print("Enter employee Number ");
       int employeeNumber=scan.nextInt();       //nextLine() is used to read integer
      

       System.out.print("Enter employee shift Number ");
       int employeeShiftNumber=scan.nextInt();
      
       System.out.print("Enter employee hourly pay ");
       int employeeHourlyPay=scan.nextInt();
  
       //Now the values are set to object properties with the help of mutator
      
object.setEmployeeName(employeeName);
       object.setEmployeeNumber(employeeNumber);
       object.setShiftNumber(employeeShiftNumber);
       object.setHourlyPay(employeeHourlyPay);
      
       //Now displaying Employee Data using accessor
      
System.out.println("\nOUTPUT");
      
       System.out.println("Name: "+object.getEmployeeName());           //calling accessor to get values
       System.out.println("Employee Number: "+object.getEmployeeNumber());
      
       if(1 == object.getShiftNumber())               //1 = Day and 2=Night Shift
           System.out.println("Shift: Day");
       else
           System.out.println("Shift: Night");
          
       System.out.println("Hourly Pay Rate: $"+object.getHourlyPay());
   }
}

Output terminal:

Add a comment
Know the answer?
Add Answer to:
(PLEASE UPLOAD ALL PARTS TO THE QUESTION) (IE: PSEUDO CODE AND JAVA CODE TOGETHER NOT ONE...
Your Answer:

Post as a guest

Your Name:

What's your source?

Earn Coins

Coins can be redeemed for fabulous gifts.

Not the answer you're looking for? Ask your own homework help question. Our experts will answer your question WITHIN MINUTES for Free.
Similar Homework Help Questions
  • (PLEASE UPLOAD ALL PARTS TO THE QUESTION) (IE: PSEUDO CODE AND JAVA CODE TOGETHER NOT ONE...

    (PLEASE UPLOAD ALL PARTS TO THE QUESTION) (IE: PSEUDO CODE AND JAVA CODE TOGETHER NOT ONE OR THE OTHER) Design an Employee class that fields for the following pieces of information: 1) Employee name 2) Employee number Next design a class named ProductionWorker that extends the Employee class. The ProductionWorker class should have fields to hold the following information: 1) Shift number (an integer, such as 1, 2, or 3) 2)Hourly pay The workday is divided into two shifts day...

  • JAVA HELP Design a class named Employee. The class should keep the following information in fields:...

    JAVA HELP Design a class named Employee. The class should keep the following information in fields: Employee name Employee number in the format XXX–L, where each X is a digit within the range 0–9 and the L is a letter within the range A–M. Hire date then, Write one or more constructors and the appropriate accessor and mutator methods for the class. Next, write a class named ProductionWorker that extends the Employee class. The ProductionWorker class should have fields to...

  • Design a class named Employee. The class should keep the following information in

    WRITE IN C++ ONLY PLEASE. IM USING VISUAL STUDIO CODE.1. Employee and ProductionWorker ClassesDesign a class named Employee. The class should keep the following information in• Employee name• Employee number• Hire dateWrite one or more constructors and the appropriate accessor and mutator functions for the class.Next, write a class named ProductionWorker that is derived from the Employee class. The ProductionWorker class should have member variables to hold the following information:• Shift (an integer)• Hourly pay rate (a double )The workday...

  • Employee and ProductionWorker Classes DONE IN C# PLEASE Create an Employee class that has properties for...

    Employee and ProductionWorker Classes DONE IN C# PLEASE Create an Employee class that has properties for the following data: • Employee name • Employee number Next, create a class named ProductionWorker that is derived from the Employee class. The ProductionWorker class should have properties to hold the following data: • Shift number (an integer, such as 1, 2, or 3) • Hourly pay rate The workday is divided into two shifts: day and night. The Shift property will hold an...

  • C++ Lab 9B Inheritance Class Production Worker Create a project C2010Lab9b; add a source file Lab...

    C++ Lab 9B Inheritance Class Production Worker Create a project C2010Lab9b; add a source file Lab9b.cpp to the project. Copy and paste the code is listed below: Next, write a class named ProductionWorker that is derived from the Employee class. The ProductionWorker class should have member variables to hold the following information: Shift (an integer) Hourly pay rate (a double) // Specification file for the ProductionWorker Class #ifndef PRODUCTION_WORKER_H #define PRODUCTION_WORKER_H #include "Employee.h" #include <string> using namespace std; class ProductionWorker...

  • Create the Python code for a program adhering to the following specifications. Write an Employee class...

    Create the Python code for a program adhering to the following specifications. Write an Employee class that keeps data attributes for the following pieces of information: - Employee Name (a string) - Employee Number (a string) Make sure to create all the accessor, mutator, and __str__ methods for the object. Next, write a class named ProductionWorker that is a subclass of the Employee class. The ProductionWorker class should keep data attributes for the following information: - Shift number (an integer,...

  • PLEASE UPLOAD or Write a simple PSEUDO CODE AND JAVA CODE for this program WITH COMMENTS...

    PLEASE UPLOAD or Write a simple PSEUDO CODE AND JAVA CODE for this program WITH COMMENTS IN BOTH TELLING WHAT EACH PART DOES. (I NEED BOTH CODES NOT JUST ONE OR THE OTHER) Problem Statement A golf club has a small tournament consisting of five golfers every weekend. The club president has asked you to design a program that does the following: Reads player’s names and their scores from the keyboard for each of the five golfers and simulates writing...

  • Please answer the following question with Java Modify the Employee and ProductionWorker classes provided below so...

    Please answer the following question with Java Modify the Employee and ProductionWorker classes provided below so they throw exceptions when the following errors occur. - The Employee class should throw an exception named InvalidEmployeeNumber when it receives an employee number that is less than 0 or greater than 9999. - The ProductionWorker class should throw an exception named InvalidShift when it receives an invalid shift. - The ProductionWorker class should thrown anexception named InvalidPayRate when it receives a negative number...

  • java code Write a class called FractionObject that represents a fraction with an integer numerator and...

    java code Write a class called FractionObject that represents a fraction with an integer numerator and denominator as fields. A Fraction Object object should have the following methods: A constructor with int numerator, int denominator as parameters - Constructs a new fraction object to represent the ratio (numerator/denominator). The denominator cannot be 0, so output a message if O is passed and set the numerator and denominator to 1. A constructor with no parameters - Constructs a new FractionObject to...

  • write in java and please code the four classes with the requirements instructed You will be...

    write in java and please code the four classes with the requirements instructed You will be writing a multiclass user management system using the java. Create a program that implements a minimum of four classes. The classes must include: 1. Employee Class with the attributes of Employee ID, First Name, Middle Initial, Last Name, Date of Employment. 2. Employee Type Class that has two instances of EmployeeType objects: salaried and hourly. Each object will have methods that calculates employees payrol...

ADVERTISEMENT
Free Homework Help App
Download From Google Play
Scan Your Homework
to Get Instant Free Answers
Need Online Homework Help?
Ask a Question
Get Answers For Free
Most questions answered within 3 hours.
ADVERTISEMENT
ADVERTISEMENT
ADVERTISEMENT