Question: Modify the assignment 3 (Classes) program to include the following elements. In the main program add a function that: Creates an Employee Class object Prompts

Modify the assignment 3 (Classes) program to include the following elements.

  1. In the main program add a function that:
    1. Creates an Employee Class object
    2. Prompts the user for data and use this data to set the object properties (name, Employee ID, hourly rate, hours worked)
    3. Return the Employee object to the main program.
    4. Call the Employee object method to return total pay
    5. Print out the total pay value to the screen.

Code:

import java.util.*;

class employee { String firstname; String lastname; int employeeID; Float hourlypay; Float hoursworked;

void Set() { Scanner ob=new Scanner(System.in); System.out.println("Enter Employee First Name :"); firstname=ob.nextLine(); System.out.println("Enter Employee Last Name :"); lastname=ob.nextLine(); System.out.println("Enter Employee ID:"); employeeID=ob.nextInt(); System.out.println("Enter Amount Paid Per Hour:"); hourlypay=ob.nextFloat(); System.out.println("Enter Hours Worked:"); hoursworked=ob.nextFloat(); }

void Get() { Float Total_pay=(hourlypay)*(hoursworked); System.out.println("Total Pay :"+Total_pay); } }

class main { public static void main(String [] args) { employee s1=new employee(); s1.Set(); s1.Get(); }

}

Step by Step Solution

There are 3 Steps involved in it

1 Expert Approved Answer
Step: 1 Unlock blur-text-image
Question Has Been Solved by an Expert!

Get step-by-step solutions from verified subject matter experts

Step: 2 Unlock
Step: 3 Unlock

Students Have Also Explored These Related Databases Questions!