Java programming Try to do the same question with Map Array

Database System Concepts
7th Edition
ISBN:9780078022159
Author:Abraham Silberschatz Professor, Henry F. Korth, S. Sudarshan
Publisher:Abraham Silberschatz Professor, Henry F. Korth, S. Sudarshan
Chapter1: Introduction
Section: Chapter Questions
Problem 1PE
icon
Related questions
Question

Java programming

Try to do the same question with Map Array  

public void set wosalarylfloat salary) {
wosalary-salary;
}
public static String get woid() {
return woid:
}
public static String get wonamel) {
class Worker {
private static String woid;
private static String woname;
private static int Wopos;
private static float wosalary;
public void set woid(String id) {
woid=id;
}
public void set woname(String name) {
return woname;
}
public static int get wopos() {
woname=name;
return wopos;
}
}
public void set woposlint ipos) {
public static float get wosalary0 {
return wosalary;
}
}
wopos=ipos;
}
Q1. (MT-2 Fall 2012)
• Write a method named "read workers" that will get a ListArray of objects (class Worker) as
an argument (named workerlist).
Your function has to ask user the worker Id, Worker Name, Worker position, and Worker
salary, and save these input as the properties of an object which has to be inserted into the
workerlist.
• On every end of the input turn, your method has to ask user as "Would you like to input for
one more worker? (Y/N)". On choise "Y" or "y", it has to read the next worker data.
Solution:
public static void read workers(List workerlist){
Worker worker char ch='N';
do {|
worker = new Worker();
worker set woidlJOptionPane showlnputDialog("Enter The Worker Id"));
worker set wonamelJOptionPane.showlnputDialog("Enter The Worker Name"));
worker set wopos lnteger.carselnt(JOptionPane.showlnputDialog(
"Enter The Worker Position")):
worker.set_wosalary(Float.parseFloat(JOptionPane.showlnputDialog(
"Enter The Worker Salary")):
workerlist.add(worker);
ch=JOptionPane.showlnputDialog("Would you want to input one more worker?(Y/N)"); //???
} while ((ch=='Y")|(sh=='y'));
}
Transcribed Image Text:public void set wosalarylfloat salary) { wosalary-salary; } public static String get woid() { return woid: } public static String get wonamel) { class Worker { private static String woid; private static String woname; private static int Wopos; private static float wosalary; public void set woid(String id) { woid=id; } public void set woname(String name) { return woname; } public static int get wopos() { woname=name; return wopos; } } public void set woposlint ipos) { public static float get wosalary0 { return wosalary; } } wopos=ipos; } Q1. (MT-2 Fall 2012) • Write a method named "read workers" that will get a ListArray of objects (class Worker) as an argument (named workerlist). Your function has to ask user the worker Id, Worker Name, Worker position, and Worker salary, and save these input as the properties of an object which has to be inserted into the workerlist. • On every end of the input turn, your method has to ask user as "Would you like to input for one more worker? (Y/N)". On choise "Y" or "y", it has to read the next worker data. Solution: public static void read workers(List workerlist){ Worker worker char ch='N'; do {| worker = new Worker(); worker set woidlJOptionPane showlnputDialog("Enter The Worker Id")); worker set wonamelJOptionPane.showlnputDialog("Enter The Worker Name")); worker set wopos lnteger.carselnt(JOptionPane.showlnputDialog( "Enter The Worker Position")): worker.set_wosalary(Float.parseFloat(JOptionPane.showlnputDialog( "Enter The Worker Salary")): workerlist.add(worker); ch=JOptionPane.showlnputDialog("Would you want to input one more worker?(Y/N)"); //??? } while ((ch=='Y")|(sh=='y')); }
Expert Solution
steps

Step by step

Solved in 2 steps

Blurred answer
Knowledge Booster
Randomized Select Algorithm
Learn more about
Need a deep-dive on the concept behind this application? Look no further. Learn more about this topic, computer-science and related others by exploring similar questions and additional content below.
Similar questions
  • SEE MORE QUESTIONS
Recommended textbooks for you
Database System Concepts
Database System Concepts
Computer Science
ISBN:
9780078022159
Author:
Abraham Silberschatz Professor, Henry F. Korth, S. Sudarshan
Publisher:
McGraw-Hill Education
Starting Out with Python (4th Edition)
Starting Out with Python (4th Edition)
Computer Science
ISBN:
9780134444321
Author:
Tony Gaddis
Publisher:
PEARSON
Digital Fundamentals (11th Edition)
Digital Fundamentals (11th Edition)
Computer Science
ISBN:
9780132737968
Author:
Thomas L. Floyd
Publisher:
PEARSON
C How to Program (8th Edition)
C How to Program (8th Edition)
Computer Science
ISBN:
9780133976892
Author:
Paul J. Deitel, Harvey Deitel
Publisher:
PEARSON
Database Systems: Design, Implementation, & Manag…
Database Systems: Design, Implementation, & Manag…
Computer Science
ISBN:
9781337627900
Author:
Carlos Coronel, Steven Morris
Publisher:
Cengage Learning
Programmable Logic Controllers
Programmable Logic Controllers
Computer Science
ISBN:
9780073373843
Author:
Frank D. Petruzella
Publisher:
McGraw-Hill Education