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 a program that implements the pseudocode below: 1. Ask the user for the number of...
Write a program that implements the pseudocode below: 1. Ask the user for the number of days until finals. 2. Print out the weeks until finals (weeks = days // 7) 3. Print out the leftover days (leftover = days % 7) Note: Always have some labeling (identifying) text to explain the meaning of any numbers printed. And, do not forget to have your name and what the program does as comments in the beginning of your file.
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.
Test all of the methods in the code below: Instantiate several Matrix objects of different sizes....
Test all of the methods in the code below: Instantiate several Matrix objects of different sizes. Make a Matrix copy from an excisting Matrix Test the equals method to show one matrix being equal and one matrix not being equal display 2 matrices using a toString method display a mtrix object before and after multiplying by a scalar after display a matrix object before and after multiplying by 0 test the matrix by matrix multiplication with at least 3 different...
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...
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          ...
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...
Write the Pseudocode for the following programming problem. Write a program that will calculate a tip...
Write the Pseudocode for the following programming problem. Write a program that will calculate a tip based on the meal price and a 6% tax on a meal price. The user will enter the meal price and the program will calculate tip, tax, and the total. The total is the meal price plus the tip plus the tax. Your program will then display the values of tip, tax, and total. The tip amounts based on the mean price are as...
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...
ADVERTISEMENT
ADVERTISEMENT
ADVERTISEMENT