0% found this document useful (0 votes)
8 views1 page

Java Employee Class Tutorial

Uploaded by

tamer121407
Copyright
© All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as DOC, PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
8 views1 page

Java Employee Class Tutorial

Uploaded by

tamer121407
Copyright
© All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as DOC, PDF, TXT or read online on Scribd

University of Bahrain

College of Information Technology


Department of Computer Science

ITCS113: Introduction to Computer Science


Tutorial(Classes)

Part (1): Class Definition


Create a Java class called Employee that includes the following:
 Instance variables: firstName (String), payrate (double), normalHours(double) and
extraHours(double).
 Constructor: A constructor that initializes all instance variables.
 Setters and Getters: Provide a setter and a getter method for each instance variable.
 Method calcPay(): This method calculates the employee’s total pay using the following
formula:
Pay = normalHours * payRate + extraHours * payRate * 2
 Method print():This method displays the employee’s name, normal hours, extra hours,
and the calculated total pay.
Part (2): Application
Write a Java application (with a main method) that does the following:
1. Prompts the user to enter: Employee name, Pay rate, Normal hours worked and Extra
hours worked
2. Creates an object of the Employee class using the entered data.
3. Calls the calcPay() and print() methods to display the results.

You might also like