عرض مشاركة واحدة
منتديات طلاب وطالبات جامعة الملك عبد العزيز منتديات طلاب وطالبات جامعة الملك عبد العزيز
قديم 23-03-2011, 09:00 PM   #7

ابنة جامعة الملك عبد العز

جامعي

 
تاريخ التسجيل: Mar 2011
التخصص: علم حاسوب
نوع الدراسة: إنتساب
المستوى: الثاني
الجنس: أنثى
المشاركات: 1
افتراضي رد: [cpcs 202 - برمجة 1] لديك سؤال , شيء غير مفهوم ,,, تفضل هنا , موضوع مفيد

ممكن أحد يساعدني في كتابة هذا الكود بلغة الجافا
لإني حاولت بس ما قدرت اطلع الناتج المطلوب بكرة عندي امتحان وما عرفت كيف احل:(
تكفون الله يخليكم تساعدونني
السؤال هو:
• Read text input from files using Scanner class
• Process text using String, and StringBuilder classes
• Write text data to text files using PrintWriter class
Problem Specification
Suppose that you were asked to write a program that can process employees records (سجلات) located in an input file named employees.data and write the new data to another file named new_employees.data. Note that every record is represented in one line.
The input file is textual, and contains the data as follows:
employees.data
ACT1032 Wael,Naser Ramallah-1230 650
ACT230 Maram,Ali Nablus-234 860
MGT1441 Salem,Rami Ramallah-2355 670
HRM2331 Ahmad,Salah Jerico-343 1200
………….
………
…..
As you can see from above, the file contains unknown number of records and every line (record) has exactly the same format, which consists (كل سطر يتكون من 4 اقسام) of 4 parts:
• First part represents the department and employee number,
example: ACT1032 : Accounting department, and employee number = 1032. Note also that departments are always represented in three characters upper case, according to the following department key table:
ACT Accounting
MGT Management
HRM Human Resources

• Second part represents: first name,second name
example: Wael,Naer : first name = Wael and last name = Naser

• Third part represents city name-B.O. Box number
example Ramallah-1230 : city = Ramallah and B.O.Box = 1230

• And last part is the salary in US Dollars
So what your program should do?
• You need to create a class the represents an employee, having these fields: number, first name, second name, city, bo box and salary. You should decide the appropriate data type for each field, and decide on appropriate constructors.
• All above fields should be private, and provide getters and setters
• Your main class should call a method fillData() that will:
o Open file employees.data
o Read data line-by-line, and process each line by extracting data and storing it in employee object.
o You should use the departments key table above to discover full department name and store it in the object. And also all other data: number, first name, last name, …etc
o The method at the end will return an array of all employees
• Then call another method and pass it the array and will write the following information on file new_employees.data respectively (بالترتيب)
o How many employee in every department
o How many employees live in Nablus
o The average of salaries of all employees.
o You can have as many methods as you think appropriate!

 

ابنة جامعة الملك عبد العز غير متواجد حالياً   رد مع اقتباس