Question
Question 1: (in java programing language) public class Worker implements Serializable { private int id; private int birthYear; private int salary; //3 private fields public
Question 1:
(in java programing language)
public class Worker implements Serializable { private int id; private int birthYear; private int salary; //3 private fields
public int getBitrhYear ( ) { return birthYear; } public int getSalary( ) { return salary; } public void setSalary (int s) { salary = s; } }
a- Write a void method that takes a string s1 representing a serial file name of Worker objects and another string s2. The method produces a new serial file (of name as the parameter s2) of all workers in input file such that the salary of workers born before 1992 is increased by 150 (other workers salary has no change).
public static void changeSalary (String s1 , String s2)
b- Write a program that reads N worker objects (N is user-input) into file: w1.ser and then call the above method changeSalaryto produce a new file: w2.ser. The program prints both files on screen (using two calls to a method printFile)
Remark: you may add constructer , toString (or print) method , and more set and get to the class worker but don't change or add any other code ,also make sure that the worker number is add by user (N is user-input)and also there (id , birthYear &salary = user input ) ((don't make any thing Random and also don't use linked list ))
Step by Step Solution
There are 3 Steps involved in it
Step: 1
Get Instant Access to Expert-Tailored Solutions
See step-by-step solutions with expert insights and AI powered tools for academic success
Step: 2
Step: 3
Ace Your Homework with AI
Get the answers you need in no time with our AI-driven, step-by-step assistance
Get Started