Question

In: Computer Science

Write and submit a test driver program employeeTest.java, the pseudocode is below. start instantiate a Employee...

Write and submit a test driver program employeeTest.java, the pseudocode is below.

start
instantiate a Employee object
get input from user for worker name
loop while user does not enter ""
   Set workers name
   get input from user for employeeId
   set workers employeeId
   get input from user for shift (day/night)
   set workers shift (input "day" = true , input "night" = false)
   get input from user workers hourly pay
   set workers hourly pay
   get input from user total hours worked
   call workers PrintPayStub method
   get input from user for next worker name
end loop
end program


Solutions

Expert Solution

import java.util.Scanner;

class Employee
{
        private String worker_name;
        private int employeeId;
        public Boolean shift;
        public int hourly_pay;
        public int total_hours;
        
        public String getWorker_name() {
                return worker_name;
        }

        public void setWorker_name(String worker_name) {
                this.worker_name = worker_name;
        }

        public int getEmployeeId() {
                return employeeId;
        }

        public void setEmployeeId(int employeeId) {
                this.employeeId = employeeId;
        }

        
        public Boolean getShift() {
                return shift;
        }

        public void setShift(Boolean shift) {
                this.shift = shift;
        }

        public int getHourly_pay() {
                return hourly_pay;
        }

        public void setHourly_pay(int hourly_pay) {
                this.hourly_pay = hourly_pay;
        }

        public int getTotal_hours() {
                return total_hours;
        }

        public void setTotal_hours(int total_hours) {
                this.total_hours = total_hours;
        }

        public void printPayStub()
        {
                System.out.println("Worker Name:"+worker_name);
                System.out.println("Worker id:"+employeeId);
                int TotalPay=total_hours*hourly_pay;
                System.out.println("Total pay:"+TotalPay);
        }
}

public class EmployeeTest {
        
        public static void main(String[] args)
        {
                String en,eShift;
                int eid,etotal,ehourly;
                Employee e=new Employee();
                System.out.print("Enter worker name:");
                Scanner sc=new Scanner(System.in);
                en=sc.nextLine();
                do
                {
                        e.setWorker_name(en);
                        System.out.print("Enter employee id:");
                        eid=sc.nextInt();
                        e.setEmployeeId(eid);
                        Scanner sc1=new Scanner(System.in);
                        System.out.print("Enter worker shift (day/night):");
                        eShift=sc1.nextLine();
                        if(eShift=="day")
                                e.setShift(true);
                        else
                                e.setShift(false);
                        System.out.print("Enter worker Hourly pay:");
                        ehourly=sc1.nextInt();
                        e.setHourly_pay(ehourly);
                        System.out.print("Enter worker Total Hours:");
                        etotal=sc1.nextInt();
                        e.setTotal_hours(etotal);
                        e.printPayStub();
                        Scanner sc2=new Scanner(System.in);
                        System.out.print("Enter worker name:");
                        en=sc2.nextLine();
                }while(en.equals(""));
        }
}

In the printPayStub method i am printing employee name and employee id along with total pay.

Output

When worker name is "" , the program will gets terminated.


Related Solutions

write pseudocode for the following problems not c code Pseudocode only Write a C program to...
write pseudocode for the following problems not c code Pseudocode only Write a C program to print all natural numbers from 1 to n. - using while loop Write a C program to print all natural numbers in reverse (from n to 1). - using while loop Write a C program to print all alphabets from a to z. - using while loop Write a C program to print all even numbers between 1 to 100. - using while loop...
Write pseudocode (3 Marks) and program structure (4 Marks) for the problem given below; In a...
Write pseudocode and program structure (4 Marks) for the problem given below; In a college, students are awarded a pass grade if their total mark is between 50-59, credit grade if the mark is between 60-69, distinction for marks between 70-79. High distinction if the mark is above or equal to 80 and fail if the mark is below 50.
Using the pseudocode found below, write only the actual (C++) code for this program. Include all...
Using the pseudocode found below, write only the actual (C++) code for this program. Include all libraries. Specification: Write a program that will repeatedly ask the user for quiz grades in the range from 0 to 20. Any negative value will act as a sentinel. When the sentinel is entered compute the average of the grades entered. Design: Constants None Variables float grade float total = 0 int count = 0 float average ------- Inital Algorithm Repeatedly ask user for...
C Program and pseudocode for this problem. Write a C program that plays the game of...
C Program and pseudocode for this problem. Write a C program that plays the game of "Guess the number" as the following: Your program choose the number to be guessed by selecting an integer at random in the rang of 1 to 1000. The program then asks the use to guess the number. If the player's guess is incorrect, your program should loop until the player finally gets the number right. Your program keeps telling the player "Too High" or...
In this exercise, you will test and debug a Future Value Program. The pseudocode of the...
In this exercise, you will test and debug a Future Value Program. The pseudocode of the program is as follows: Display user message WHILE user wants to continue           get monthly investment, yearly interest rate, and years           convert yearly interest rate to monthly interest rate           convert years to months           set the future value to zero           FOR each month                     add monthly investment amount to future value                     calculate interest for month                     add interest to future value          ...
In this exercise, you will test and debug a Future Value Program. The pseudocode of the...
In this exercise, you will test and debug a Future Value Program. The pseudocode of the program is as follows: Display user message WHILE user wants to continue           get monthly investment, yearly interest rate, and years           convert yearly interest rate to monthly interest rate           convert years to months           set the future value to zero           FOR each month                     add monthly investment amount to future value                     calculate interest for month                     add interest to future value          ...
write pseudocode not c program If- else programming exercises 1.    Write a C program to find...
write pseudocode not c program If- else programming exercises 1.    Write a C program to find maximum between two numbers. 2.    Write a C program to find maximum between three numbers. 3.    Write a C program to check whether a number is negative, positive or zero. 4.    Write a C program to check whether a number is divisible by 5 and 11 or not. 5.    Write a C program to check whether a number is even or odd. 6.    Write...
DESIGN A FLOWCHART IN FLOWGORITHM AND WRITE THE PSEUDOCODE Number Analysis Program Design a program that...
DESIGN A FLOWCHART IN FLOWGORITHM AND WRITE THE PSEUDOCODE Number Analysis Program Design a program that asks the user to enter a series of 20 numbers. The program should store the numbers in an array and then display the following data: The lowest number in the array. The highest number in the array. The total of the numbers in the array. The average of the numbers in the array. PLEASE AND THANK YOU
java Write our Test Driver program that tests our Classes and Class Relationship How we calculate...
java Write our Test Driver program that tests our Classes and Class Relationship How we calculate Net Pay after calculating taxes and deductions taxes: regNetPay = regPay - (regPay * STATE_TAX) - (regPay * FED_TAX) + (dependents * .03 * regPay ) overtimeNetPay = overtimePay - (overtimePay * STATE_TAX) - (overtimePay * FED_TAX) + (dependents * .02 * overtimePay ) Example printPayStub() output: Employee: Ochoa Employee ID: 1234 Hourly Pay: $25.00 Shift: Days Dependents: 2 Hours Worked: 50 RegGrossPay: $1,000.00...
write a program including the pseudocode write a progrqm that outputs a grade based on user...
write a program including the pseudocode write a progrqm that outputs a grade based on user input. an example if the user enters an 80 the program will output the grade is B. grading scale: 90-100=A 80-89=B 70-79=C 65-69=D 0-64=F
ADVERTISEMENT
ADVERTISEMENT
ADVERTISEMENT