1. Create custom exceptions for invalid employee code, basic salary, and job inputs. Validate user input and throw exceptions for invalid data, re-prompting the user until valid data is entered. Calculate and display salary details.
2. Write a program that creates 50 threads in reverse order, with each thread printing its number.
3. Implement Runnable to print "Hello, World!" with timestamps every second for 10 greetings, ending with "Goodbye!!".
Download as ODT, PDF, TXT or read online on Scribd
0 ratings0% found this document useful (0 votes)
20 views
Enterprise Java Lab - Assignment 4
1. Create custom exceptions for invalid employee code, basic salary, and job inputs. Validate user input and throw exceptions for invalid data, re-prompting the user until valid data is entered. Calculate and display salary details.
2. Write a program that creates 50 threads in reverse order, with each thread printing its number.
3. Implement Runnable to print "Hello, World!" with timestamps every second for 10 greetings, ending with "Goodbye!!".
Download as ODT, PDF, TXT or read online on Scribd
You are on page 1/ 1
Enterprise Java Lab Assignment 4
Note: 1. Inputs must be dynamic in nature for all the programs
2. Use any editor or tool for executing the following programs
01-08-2022
1 Create a user defined exception called EmpCodeException, BasicException and
JobException which will be thrown when empnode is not of 5 characters and should consist of atleast one capital letter and minimum of one digit, basic is not between 2000 and 7000 and if job is not “manager” or analyst or clerk with appropriate error message. In an executable class accept ,empcode, ename, job, basic. Validate the input and if invalid data entered, throw the respective exception and accept the respective data once again. Calculate da, hra, net and display the details. 2 Write a program called GreetReverse.java that creates a thread (let's call it Thread 1). Thread 1 creates another thread (Thread 2); Thread 2 creates Thread 3; and so on, up to Thread 50. Each thread should print "Hello from Thread <num>!", but you should structure your program such that the threads print their greetings in reverse order. 3 Write a class that implements Runnable interface. Print ten greetings of Hello, World! in the format “Fri Jun 11 23:12:12 PST 2021 Hello, World!” with a time delay of 1 second between each greeting. To display the time, use Date class of java.util package. When every thread dies, display the message “Goodbye!!” 4 Write a program to demonstrate the life cycle of a thread. Use the getState() method of a Thread class to get the current state of a thread. 5 Write a Java Program to create a chatting application. 6 Write a program to perform banking operations using threads. 7 Create two threads, one Emp thread that had data elements empno, ename, basic, da, hra, net, getEmp(), calculate() and displayEmp() and run() methods, Call getEmp(), 8 calculate() and displayEmp() methods inside run. Similarly have Student thread with data elements studno, name, m1, m2, m3, total and percentage, getStudent(), calculate() and displayStudent() and run(). GetStudent(), calculate() and displayStudent() should be called inside run(). In an executable class create threads Emp and Student and start them. But see to it that the threads run one after the other.