SlideShare a Scribd company logo
1 of 7
Download to read offline
Workshop 2
Q1. Write java program to manage fractions with addition, subtraction, multiplication and
division.
Q2. Vehicle Management System, including: car, motorbike, truck. Each of the Vehicle has
attributes of manufacturer, manufacture year, cost, color. Moreover, cars have types of engine,
number of seats. Motorbikes have power and trucks have load.
Code a class named Car, Motor, Truck are directly derived from base class Vehicle object.
Write a program with the following functions:
1. Input data of vehicles (validation data if necessarily)
2. To view the details of the vehicles (3 vehicles in one table or one for each table), to count
the number of vehicles in the following table.
3. Searching by manufacturer, manufacture year, cost, color, types of engine, seats, …
(exactly or approximately)
4. Searching from .. to…( manufacture year, cost)
5. Sorting by manufacturer, manufacture year, cost, color, types of engine, seats, …
6. To calculate statistics
Q3.
Library Management, including Book, Magazine, Newspaper. Each of the Document has
attributes of code, publisher and circulation (tổng số phát hành). Moreover, Books have author, title
and the number of pages. Magazines have issue number, monthly release. Newspapers have
Release date.
Code a class named Book, Magazine, Newspaper are directly derived from base class
Document object.
Write a program with the following functions:
1. Input data of documents (validation data if necessarily)
2. To view the details of all of documents (3 documents in one table or one for each table),
to count the number of documents in the following table.
3. Remove, update for a document (enter a code of document)
4. Searching by code, publisher, circulation, author, title and the number of pages … (exactly
or approximately)
5. Searching from .. to…( circulation, the number of pages, monthly release, Release date)
6. Sorting by code, publisher, circulation, author, title and the number of pages …
7. To calculate statistics
Q4.
One IT center requies full-time and part-time teachers. Full-time teacher information has teacher
code, full name, email, Professor (Học hàm) (non, Prof. (Professor), Assoc. Prof. (Asscociate
Professor), Assist. Prof. (Assistant Professor)), University degree (học vị) (Bachelor, Master,
Post Doctor), address, phone, number of teaching hours per month, basic pay (lương cơ bản), pay
rate (hệ số lương) (Bachelor: 1, Master: 1.1, Post Doctor: 1.2 and Prof. : +0.3, Assoc. Prof. +0.2,
Assist. Prof. +0.1), Norm hour (số giờ định mức), overtime hour (50.000 vnd/1h).
Part-time teacher information has teacher code, full name, email, Professor (non, Prof.
(Professor), Assoc. Prof. (Asscociate Professor), Assist. Prof. (Assistant Professor)), University
degree (Bachelor, Master, Post Doctor), address, phone, number of teaching hours per month,
pay rate (Bachelor: 1, Master: 1.1, Post Doctor: 1.2 and Prof. : +0.3, Assoc. Prof. +0.2, Assist.
Prof. +0.1), office, (200.000 vnd/1h).
Write a program with the following functions:
1. Enter the information for full-time and part-time teacher (validation data if necessarily)
2. Display all teacher information (in one table or one for each table), to count the number
of teachers in the following table.
3. Remove, update a teacher (enter code of teacher)
4. Searching by code, full name, email, Professor, Assoc. Prof., University degree, address,
phone, number of teaching hours per month, basic pay, pay rate … (exactly or
approximately)
5. Searching from .. to…( number of teaching hours per month, pay rate, …)
6. Sorting by code, full name, email, Professor, Assoc. Prof., University degree, address,
phone, number of teaching hours per month, basic pay, pay rate …
7. To calculate statistics
Q5. We have the design for Phone number:
PhoneNumber
- int area
- String number
+ PhoneNumber()
+ PhoneNumber(int a, String n);
+ void display();
IntPhoneNumber
- String countryCode
+ IntPhoneNumber ()
+IntPhoneNumber (String cc, int a, String n);
+ void display();
Implement the above classes and make your own main program to test all the above
methods. The output of your program something look like:
Enter list of phone numbers
-----------------------------------------
Type of phone number ? (1 – local phone, 2 – Inter phone number,
0 - exit): 1
Enter area code: 111
Enter number: 111111
Type of phone number ? (1 – local phone, 2 – Inter phone number,
0 - exit): 2
Enter country code: 22
Enter area code: 222
Enter number: 222222
Type of phone number ? (1 – local phone, 2 – Inter phone number,
0 - exit): 1
Enter area code: 333
Enter number: 333333
Type of phone number ? (1 – local phone, 2 – Inter phone number,
0 - exit): 2
Enter country code: 44
Enter area code: 444
Enter number: 444444
Type of phone number ? (1 – local phone, 2 – Inter phone number,
0 - exit): 0
List of phone number:
----------------------------------------
111 – 111111
22 – 222 – 222222
333 – 333333
44 - 444 – 444444
Note: You can using an array of base class PhoneNumber object
PhoneNumber phonelist[] = new PhoneNumber[1000]; or
ArrayList< PhoneNumber > phonelist = new ArrayList< PhoneNumber >();
Q6. We have the design for Staff:
Person
- String name
+ Person()
+ Person(String n)
+ void display();
+ double getSalary();
Officer
- double bSalary
+ Officer ()
+Officer (String n, double s)
+ void display();
+ double getSalary();
- Person. getSalary() is an abstract method
- Worker and Officer are subclasses of Person and Worker.salary = hrs * rate
Implement the above classes and make your own main program to test all the above methods
Add the below code to your main function and run
Q7. Create a class named DictionaryWord as:
DictionaryWord
- word: String
- meanings: String
+ DictionaryWord (String word, String meanings)
+ getWord(): String
+ setWord (String word): void
+ getMeanings(): String
+ setMeanings(String meanings): void
Write a program with the following requirements:
Creates 8 DictionaryWord objects with:
● Word and meanings as the table:
Word Meanings
bank robber Steals money from a bank
Burglar Breaks into a home to steal things
Worker
- double hrs
- final double RATE = 5.5
+ Worker()
+Worker(String n, double hrs)
+ void display();
+ double getSalary();
Forger Makes an illegal copy of something
Hacker Breaks into a computer system
Hijacker Takes control of an airplane
Kidnapper Holds someone for ransom money
Mugger Attacks and steals money from someone
Murderer Kills another person
● Ensure that there is no duplicate DictionaryWord objects (02 DictionaryWord objects a
and b are equal when a.word=b.word).
Displays all DictionaryWord in ascending order of word with the format as:
<<no>.<<word>>
<<meanings>>
<<no>.<<word>>
<<meanings>>
Where: <<no>>=1,2…
Hint:
● class DictionaryWord implements Comparable to order 2 DictionaryWord objects.
● override equals(..) method to compare 2 DictionaryWord objects.
● override toString()
● use Set to ensure no duplicate.
● use support class Collections to sort DictionaryWord objects.
Q8 :
1. Create a class Student includes name, age, mark and necessary methods. Using
FileWriter, FileReader and BufferedReader to write a program that has functional menu:
Menu
-------------------------------------------------
1. Add a list of Students and save to File
2. Loading list of Students from a File
3. Exit
Your choice: _
+ Save to File: input information of several students and write that information into a text file,
each student in a line (use tabs to separate the fields)
+ Read File: read and display information of students
Accept a file name from users and display the content of entered file. Display the error
message if that file does not exists.

More Related Content

What's hot

What's hot (18)

DF1 - Py - Ovcharenko - Theano Tutorial
DF1 - Py - Ovcharenko - Theano TutorialDF1 - Py - Ovcharenko - Theano Tutorial
DF1 - Py - Ovcharenko - Theano Tutorial
 
Two dimensional arrays
Two dimensional arraysTwo dimensional arrays
Two dimensional arrays
 
Arrays and library functions
Arrays and library functionsArrays and library functions
Arrays and library functions
 
8th alg -l8.1
8th alg -l8.18th alg -l8.1
8th alg -l8.1
 
Arrays in C
Arrays in CArrays in C
Arrays in C
 
Arrays and Lists in C#, Java, Python and JavaScript
Arrays and Lists in C#, Java, Python and JavaScriptArrays and Lists in C#, Java, Python and JavaScript
Arrays and Lists in C#, Java, Python and JavaScript
 
Thesis PPT
Thesis PPTThesis PPT
Thesis PPT
 
Two dimensional array
Two dimensional arrayTwo dimensional array
Two dimensional array
 
Arrays
ArraysArrays
Arrays
 
Two dimensional array
Two dimensional arrayTwo dimensional array
Two dimensional array
 
Paper no. 4
Paper no. 4Paper no. 4
Paper no. 4
 
Write a complete C++ program that does the following: 1. The program will c...
Write a complete C++ program that does the following:   1. The program will c...Write a complete C++ program that does the following:   1. The program will c...
Write a complete C++ program that does the following: 1. The program will c...
 
Array notes
Array notesArray notes
Array notes
 
CP Handout#10
CP Handout#10CP Handout#10
CP Handout#10
 
Array
ArrayArray
Array
 
C programming session 04
C programming session 04C programming session 04
C programming session 04
 
Whiteboarding Coding Challenges in Python
Whiteboarding Coding Challenges in PythonWhiteboarding Coding Challenges in Python
Whiteboarding Coding Challenges in Python
 
C Programming : Arrays
C Programming : ArraysC Programming : Arrays
C Programming : Arrays
 

Similar to Exercise2 java

python_lab_manual_final (1).pdf
python_lab_manual_final (1).pdfpython_lab_manual_final (1).pdf
python_lab_manual_final (1).pdfkeerthu0442
 
Lab 4 jawapan (sugentiran mane)
Lab 4 jawapan (sugentiran mane)Lab 4 jawapan (sugentiran mane)
Lab 4 jawapan (sugentiran mane)Yugeswary
 
CS10 Python Programming Homework 4 40 points Lists, Tupl.docx
CS10 Python Programming Homework 4 40 points Lists, Tupl.docxCS10 Python Programming Homework 4 40 points Lists, Tupl.docx
CS10 Python Programming Homework 4 40 points Lists, Tupl.docxmydrynan
 
Python programming workshop session 3
Python programming workshop session 3Python programming workshop session 3
Python programming workshop session 3Abdul Haseeb
 
Assignment DetailsYou have learned that some markets are compet.docx
Assignment DetailsYou have learned that some markets are compet.docxAssignment DetailsYou have learned that some markets are compet.docx
Assignment DetailsYou have learned that some markets are compet.docxfaithxdunce63732
 
This is my code but not complete, please complete my.pdf
This is my code but not complete, please complete my.pdfThis is my code but not complete, please complete my.pdf
This is my code but not complete, please complete my.pdffashionbigchennai
 
A2 databases
A2 databasesA2 databases
A2 databasesc.west
 
Lab6: I/O and Arrays
Lab6: I/O and ArraysLab6: I/O and Arrays
Lab6: I/O and Arraysenidcruz
 
JAVA practical Exam Questions (1).docx
JAVA practical Exam Questions (1).docxJAVA practical Exam Questions (1).docx
JAVA practical Exam Questions (1).docxLucky Ally
 
2021 icse reducedsylabiix-computer applications
2021 icse reducedsylabiix-computer applications2021 icse reducedsylabiix-computer applications
2021 icse reducedsylabiix-computer applicationsVahabshaik Shai
 
Micro project project co 3i
Micro project project co 3iMicro project project co 3i
Micro project project co 3iARVIND SARDAR
 

Similar to Exercise2 java (20)

Numerical data.
Numerical data.Numerical data.
Numerical data.
 
python_lab_manual_final (1).pdf
python_lab_manual_final (1).pdfpython_lab_manual_final (1).pdf
python_lab_manual_final (1).pdf
 
Mmt 001
Mmt 001Mmt 001
Mmt 001
 
Lab 4 jawapan (sugentiran mane)
Lab 4 jawapan (sugentiran mane)Lab 4 jawapan (sugentiran mane)
Lab 4 jawapan (sugentiran mane)
 
CS10 Python Programming Homework 4 40 points Lists, Tupl.docx
CS10 Python Programming Homework 4 40 points Lists, Tupl.docxCS10 Python Programming Homework 4 40 points Lists, Tupl.docx
CS10 Python Programming Homework 4 40 points Lists, Tupl.docx
 
Python programming workshop session 3
Python programming workshop session 3Python programming workshop session 3
Python programming workshop session 3
 
paython practical
paython practical paython practical
paython practical
 
Assignment DetailsYou have learned that some markets are compet.docx
Assignment DetailsYou have learned that some markets are compet.docxAssignment DetailsYou have learned that some markets are compet.docx
Assignment DetailsYou have learned that some markets are compet.docx
 
07. Arrays
07. Arrays07. Arrays
07. Arrays
 
C- Programming Assignment 3
C- Programming Assignment 3C- Programming Assignment 3
C- Programming Assignment 3
 
This is my code but not complete, please complete my.pdf
This is my code but not complete, please complete my.pdfThis is my code but not complete, please complete my.pdf
This is my code but not complete, please complete my.pdf
 
Project3
Project3Project3
Project3
 
A2 databases
A2 databasesA2 databases
A2 databases
 
Module 1 programs
Module 1 programsModule 1 programs
Module 1 programs
 
Lab6: I/O and Arrays
Lab6: I/O and ArraysLab6: I/O and Arrays
Lab6: I/O and Arrays
 
JAVA practical Exam Questions (1).docx
JAVA practical Exam Questions (1).docxJAVA practical Exam Questions (1).docx
JAVA practical Exam Questions (1).docx
 
COM1407: Arrays
COM1407: ArraysCOM1407: Arrays
COM1407: Arrays
 
2021 icse reducedsylabiix-computer applications
2021 icse reducedsylabiix-computer applications2021 icse reducedsylabiix-computer applications
2021 icse reducedsylabiix-computer applications
 
Micro project project co 3i
Micro project project co 3iMicro project project co 3i
Micro project project co 3i
 
Report 02(Binary Search)
Report 02(Binary Search)Report 02(Binary Search)
Report 02(Binary Search)
 

More from NguynMinh294

Slide An toàn mạng nâng cao PTIT
Slide An toàn mạng nâng cao PTITSlide An toàn mạng nâng cao PTIT
Slide An toàn mạng nâng cao PTITNguynMinh294
 
Phân tích thiết kế hệ thống thông tin PTIT
Phân tích thiết kế hệ thống thông tin PTIT Phân tích thiết kế hệ thống thông tin PTIT
Phân tích thiết kế hệ thống thông tin PTIT NguynMinh294
 
Bài giảng mật mã học cơ sở PTIT
Bài giảng mật mã học cơ sở PTITBài giảng mật mã học cơ sở PTIT
Bài giảng mật mã học cơ sở PTITNguynMinh294
 
Bài giảng an toàn ứng dụng web và csdl PTIT
Bài giảng an toàn ứng dụng web và csdl PTITBài giảng an toàn ứng dụng web và csdl PTIT
Bài giảng an toàn ứng dụng web và csdl PTITNguynMinh294
 
Bài giảng an toàn ứng dụng web và csdl PTIT
Bài giảng an toàn ứng dụng web và csdl PTITBài giảng an toàn ứng dụng web và csdl PTIT
Bài giảng an toàn ứng dụng web và csdl PTITNguynMinh294
 
Bài giảng kiểm thử xâm nhập PTIT
Bài giảng kiểm thử xâm nhập PTITBài giảng kiểm thử xâm nhập PTIT
Bài giảng kiểm thử xâm nhập PTITNguynMinh294
 
Bài giảng ký thuật theo dõi giám sát mạng PTIT
Bài giảng ký thuật theo dõi giám sát mạng PTITBài giảng ký thuật theo dõi giám sát mạng PTIT
Bài giảng ký thuật theo dõi giám sát mạng PTITNguynMinh294
 
Giáo trình mạng máy tính PTIT
Giáo trình mạng máy tính PTITGiáo trình mạng máy tính PTIT
Giáo trình mạng máy tính PTITNguynMinh294
 
Ktvxl chuong 5 - cac phuong phap vao ra du lieu
Ktvxl chuong 5 - cac phuong phap vao ra du lieuKtvxl chuong 5 - cac phuong phap vao ra du lieu
Ktvxl chuong 5 - cac phuong phap vao ra du lieuNguynMinh294
 
Ktvxl chuong 4 - phoi ghep
Ktvxl chuong 4 - phoi ghepKtvxl chuong 4 - phoi ghep
Ktvxl chuong 4 - phoi ghepNguynMinh294
 
Ktvxl chuong 3 - hop ngu 8088
Ktvxl chuong 3 - hop ngu 8088Ktvxl chuong 3 - hop ngu 8088
Ktvxl chuong 3 - hop ngu 8088NguynMinh294
 
Ktvxl chuong 2 - 8086-8088
Ktvxl chuong 2 - 8086-8088Ktvxl chuong 2 - 8086-8088
Ktvxl chuong 2 - 8086-8088NguynMinh294
 
Ktvxl chuong 1 - tong quan
Ktvxl chuong 1 - tong quanKtvxl chuong 1 - tong quan
Ktvxl chuong 1 - tong quanNguynMinh294
 
bài giảng ký thuật vi xử lý PTIT
bài giảng ký thuật vi xử lý PTITbài giảng ký thuật vi xử lý PTIT
bài giảng ký thuật vi xử lý PTITNguynMinh294
 
đề thi java ptit
đề thi java ptitđề thi java ptit
đề thi java ptitNguynMinh294
 
Java exercises part 2
Java exercises part 2Java exercises part 2
Java exercises part 2NguynMinh294
 
Java exercises part 1
Java exercises part 1Java exercises part 1
Java exercises part 1NguynMinh294
 
Giáo trình hệ điều hành PTIT
Giáo trình hệ điều hành PTITGiáo trình hệ điều hành PTIT
Giáo trình hệ điều hành PTITNguynMinh294
 

More from NguynMinh294 (20)

Slide An toàn mạng nâng cao PTIT
Slide An toàn mạng nâng cao PTITSlide An toàn mạng nâng cao PTIT
Slide An toàn mạng nâng cao PTIT
 
Phân tích thiết kế hệ thống thông tin PTIT
Phân tích thiết kế hệ thống thông tin PTIT Phân tích thiết kế hệ thống thông tin PTIT
Phân tích thiết kế hệ thống thông tin PTIT
 
Bài giảng mật mã học cơ sở PTIT
Bài giảng mật mã học cơ sở PTITBài giảng mật mã học cơ sở PTIT
Bài giảng mật mã học cơ sở PTIT
 
Bài giảng an toàn ứng dụng web và csdl PTIT
Bài giảng an toàn ứng dụng web và csdl PTITBài giảng an toàn ứng dụng web và csdl PTIT
Bài giảng an toàn ứng dụng web và csdl PTIT
 
Bài giảng an toàn ứng dụng web và csdl PTIT
Bài giảng an toàn ứng dụng web và csdl PTITBài giảng an toàn ứng dụng web và csdl PTIT
Bài giảng an toàn ứng dụng web và csdl PTIT
 
Bài giảng kiểm thử xâm nhập PTIT
Bài giảng kiểm thử xâm nhập PTITBài giảng kiểm thử xâm nhập PTIT
Bài giảng kiểm thử xâm nhập PTIT
 
Bài giảng ký thuật theo dõi giám sát mạng PTIT
Bài giảng ký thuật theo dõi giám sát mạng PTITBài giảng ký thuật theo dõi giám sát mạng PTIT
Bài giảng ký thuật theo dõi giám sát mạng PTIT
 
Giáo trình mạng máy tính PTIT
Giáo trình mạng máy tính PTITGiáo trình mạng máy tính PTIT
Giáo trình mạng máy tính PTIT
 
Ktvxl chuong 5 - cac phuong phap vao ra du lieu
Ktvxl chuong 5 - cac phuong phap vao ra du lieuKtvxl chuong 5 - cac phuong phap vao ra du lieu
Ktvxl chuong 5 - cac phuong phap vao ra du lieu
 
Ktvxl chuong 4 - phoi ghep
Ktvxl chuong 4 - phoi ghepKtvxl chuong 4 - phoi ghep
Ktvxl chuong 4 - phoi ghep
 
Ktvxl chuong 3 - hop ngu 8088
Ktvxl chuong 3 - hop ngu 8088Ktvxl chuong 3 - hop ngu 8088
Ktvxl chuong 3 - hop ngu 8088
 
Ktvxl chuong 2 - 8086-8088
Ktvxl chuong 2 - 8086-8088Ktvxl chuong 2 - 8086-8088
Ktvxl chuong 2 - 8086-8088
 
Ktvxl chuong 1 - tong quan
Ktvxl chuong 1 - tong quanKtvxl chuong 1 - tong quan
Ktvxl chuong 1 - tong quan
 
bài giảng ký thuật vi xử lý PTIT
bài giảng ký thuật vi xử lý PTITbài giảng ký thuật vi xử lý PTIT
bài giảng ký thuật vi xử lý PTIT
 
đề thi java ptit
đề thi java ptitđề thi java ptit
đề thi java ptit
 
Java exercises part 2
Java exercises part 2Java exercises part 2
Java exercises part 2
 
Java exercises part 1
Java exercises part 1Java exercises part 1
Java exercises part 1
 
Bai tap3 java
Bai tap3 javaBai tap3 java
Bai tap3 java
 
Bai tap2 java
Bai tap2 javaBai tap2 java
Bai tap2 java
 
Giáo trình hệ điều hành PTIT
Giáo trình hệ điều hành PTITGiáo trình hệ điều hành PTIT
Giáo trình hệ điều hành PTIT
 

Recently uploaded

SOCIAL AND HISTORICAL CONTEXT - LFTVD.pptx
SOCIAL AND HISTORICAL CONTEXT - LFTVD.pptxSOCIAL AND HISTORICAL CONTEXT - LFTVD.pptx
SOCIAL AND HISTORICAL CONTEXT - LFTVD.pptxiammrhaywood
 
Organic Name Reactions for the students and aspirants of Chemistry12th.pptx
Organic Name Reactions  for the students and aspirants of Chemistry12th.pptxOrganic Name Reactions  for the students and aspirants of Chemistry12th.pptx
Organic Name Reactions for the students and aspirants of Chemistry12th.pptxVS Mahajan Coaching Centre
 
call girls in Kamla Market (DELHI) 🔝 >༒9953330565🔝 genuine Escort Service 🔝✔️✔️
call girls in Kamla Market (DELHI) 🔝 >༒9953330565🔝 genuine Escort Service 🔝✔️✔️call girls in Kamla Market (DELHI) 🔝 >༒9953330565🔝 genuine Escort Service 🔝✔️✔️
call girls in Kamla Market (DELHI) 🔝 >༒9953330565🔝 genuine Escort Service 🔝✔️✔️9953056974 Low Rate Call Girls In Saket, Delhi NCR
 
POINT- BIOCHEMISTRY SEM 2 ENZYMES UNIT 5.pptx
POINT- BIOCHEMISTRY SEM 2 ENZYMES UNIT 5.pptxPOINT- BIOCHEMISTRY SEM 2 ENZYMES UNIT 5.pptx
POINT- BIOCHEMISTRY SEM 2 ENZYMES UNIT 5.pptxSayali Powar
 
Software Engineering Methodologies (overview)
Software Engineering Methodologies (overview)Software Engineering Methodologies (overview)
Software Engineering Methodologies (overview)eniolaolutunde
 
History Class XII Ch. 3 Kinship, Caste and Class (1).pptx
History Class XII Ch. 3 Kinship, Caste and Class (1).pptxHistory Class XII Ch. 3 Kinship, Caste and Class (1).pptx
History Class XII Ch. 3 Kinship, Caste and Class (1).pptxsocialsciencegdgrohi
 
Introduction to ArtificiaI Intelligence in Higher Education
Introduction to ArtificiaI Intelligence in Higher EducationIntroduction to ArtificiaI Intelligence in Higher Education
Introduction to ArtificiaI Intelligence in Higher Educationpboyjonauth
 
CARE OF CHILD IN INCUBATOR..........pptx
CARE OF CHILD IN INCUBATOR..........pptxCARE OF CHILD IN INCUBATOR..........pptx
CARE OF CHILD IN INCUBATOR..........pptxGaneshChakor2
 
BASLIQ CURRENT LOOKBOOK LOOKBOOK(1) (1).pdf
BASLIQ CURRENT LOOKBOOK  LOOKBOOK(1) (1).pdfBASLIQ CURRENT LOOKBOOK  LOOKBOOK(1) (1).pdf
BASLIQ CURRENT LOOKBOOK LOOKBOOK(1) (1).pdfSoniaTolstoy
 
Sanyam Choudhary Chemistry practical.pdf
Sanyam Choudhary Chemistry practical.pdfSanyam Choudhary Chemistry practical.pdf
Sanyam Choudhary Chemistry practical.pdfsanyamsingh5019
 
_Math 4-Q4 Week 5.pptx Steps in Collecting Data
_Math 4-Q4 Week 5.pptx Steps in Collecting Data_Math 4-Q4 Week 5.pptx Steps in Collecting Data
_Math 4-Q4 Week 5.pptx Steps in Collecting DataJhengPantaleon
 
Science 7 - LAND and SEA BREEZE and its Characteristics
Science 7 - LAND and SEA BREEZE and its CharacteristicsScience 7 - LAND and SEA BREEZE and its Characteristics
Science 7 - LAND and SEA BREEZE and its CharacteristicsKarinaGenton
 
Blooming Together_ Growing a Community Garden Worksheet.docx
Blooming Together_ Growing a Community Garden Worksheet.docxBlooming Together_ Growing a Community Garden Worksheet.docx
Blooming Together_ Growing a Community Garden Worksheet.docxUnboundStockton
 
भारत-रोम व्यापार.pptx, Indo-Roman Trade,
भारत-रोम व्यापार.pptx, Indo-Roman Trade,भारत-रोम व्यापार.pptx, Indo-Roman Trade,
भारत-रोम व्यापार.pptx, Indo-Roman Trade,Virag Sontakke
 
A Critique of the Proposed National Education Policy Reform
A Critique of the Proposed National Education Policy ReformA Critique of the Proposed National Education Policy Reform
A Critique of the Proposed National Education Policy ReformChameera Dedduwage
 
Pharmacognosy Flower 3. Compositae 2023.pdf
Pharmacognosy Flower 3. Compositae 2023.pdfPharmacognosy Flower 3. Compositae 2023.pdf
Pharmacognosy Flower 3. Compositae 2023.pdfMahmoud M. Sallam
 
Employee wellbeing at the workplace.pptx
Employee wellbeing at the workplace.pptxEmployee wellbeing at the workplace.pptx
Employee wellbeing at the workplace.pptxNirmalaLoungPoorunde1
 
Alper Gobel In Media Res Media Component
Alper Gobel In Media Res Media ComponentAlper Gobel In Media Res Media Component
Alper Gobel In Media Res Media ComponentInMediaRes1
 

Recently uploaded (20)

SOCIAL AND HISTORICAL CONTEXT - LFTVD.pptx
SOCIAL AND HISTORICAL CONTEXT - LFTVD.pptxSOCIAL AND HISTORICAL CONTEXT - LFTVD.pptx
SOCIAL AND HISTORICAL CONTEXT - LFTVD.pptx
 
Organic Name Reactions for the students and aspirants of Chemistry12th.pptx
Organic Name Reactions  for the students and aspirants of Chemistry12th.pptxOrganic Name Reactions  for the students and aspirants of Chemistry12th.pptx
Organic Name Reactions for the students and aspirants of Chemistry12th.pptx
 
call girls in Kamla Market (DELHI) 🔝 >༒9953330565🔝 genuine Escort Service 🔝✔️✔️
call girls in Kamla Market (DELHI) 🔝 >༒9953330565🔝 genuine Escort Service 🔝✔️✔️call girls in Kamla Market (DELHI) 🔝 >༒9953330565🔝 genuine Escort Service 🔝✔️✔️
call girls in Kamla Market (DELHI) 🔝 >༒9953330565🔝 genuine Escort Service 🔝✔️✔️
 
POINT- BIOCHEMISTRY SEM 2 ENZYMES UNIT 5.pptx
POINT- BIOCHEMISTRY SEM 2 ENZYMES UNIT 5.pptxPOINT- BIOCHEMISTRY SEM 2 ENZYMES UNIT 5.pptx
POINT- BIOCHEMISTRY SEM 2 ENZYMES UNIT 5.pptx
 
Software Engineering Methodologies (overview)
Software Engineering Methodologies (overview)Software Engineering Methodologies (overview)
Software Engineering Methodologies (overview)
 
History Class XII Ch. 3 Kinship, Caste and Class (1).pptx
History Class XII Ch. 3 Kinship, Caste and Class (1).pptxHistory Class XII Ch. 3 Kinship, Caste and Class (1).pptx
History Class XII Ch. 3 Kinship, Caste and Class (1).pptx
 
Introduction to ArtificiaI Intelligence in Higher Education
Introduction to ArtificiaI Intelligence in Higher EducationIntroduction to ArtificiaI Intelligence in Higher Education
Introduction to ArtificiaI Intelligence in Higher Education
 
CARE OF CHILD IN INCUBATOR..........pptx
CARE OF CHILD IN INCUBATOR..........pptxCARE OF CHILD IN INCUBATOR..........pptx
CARE OF CHILD IN INCUBATOR..........pptx
 
BASLIQ CURRENT LOOKBOOK LOOKBOOK(1) (1).pdf
BASLIQ CURRENT LOOKBOOK  LOOKBOOK(1) (1).pdfBASLIQ CURRENT LOOKBOOK  LOOKBOOK(1) (1).pdf
BASLIQ CURRENT LOOKBOOK LOOKBOOK(1) (1).pdf
 
Sanyam Choudhary Chemistry practical.pdf
Sanyam Choudhary Chemistry practical.pdfSanyam Choudhary Chemistry practical.pdf
Sanyam Choudhary Chemistry practical.pdf
 
_Math 4-Q4 Week 5.pptx Steps in Collecting Data
_Math 4-Q4 Week 5.pptx Steps in Collecting Data_Math 4-Q4 Week 5.pptx Steps in Collecting Data
_Math 4-Q4 Week 5.pptx Steps in Collecting Data
 
Science 7 - LAND and SEA BREEZE and its Characteristics
Science 7 - LAND and SEA BREEZE and its CharacteristicsScience 7 - LAND and SEA BREEZE and its Characteristics
Science 7 - LAND and SEA BREEZE and its Characteristics
 
9953330565 Low Rate Call Girls In Rohini Delhi NCR
9953330565 Low Rate Call Girls In Rohini  Delhi NCR9953330565 Low Rate Call Girls In Rohini  Delhi NCR
9953330565 Low Rate Call Girls In Rohini Delhi NCR
 
Blooming Together_ Growing a Community Garden Worksheet.docx
Blooming Together_ Growing a Community Garden Worksheet.docxBlooming Together_ Growing a Community Garden Worksheet.docx
Blooming Together_ Growing a Community Garden Worksheet.docx
 
भारत-रोम व्यापार.pptx, Indo-Roman Trade,
भारत-रोम व्यापार.pptx, Indo-Roman Trade,भारत-रोम व्यापार.pptx, Indo-Roman Trade,
भारत-रोम व्यापार.pptx, Indo-Roman Trade,
 
A Critique of the Proposed National Education Policy Reform
A Critique of the Proposed National Education Policy ReformA Critique of the Proposed National Education Policy Reform
A Critique of the Proposed National Education Policy Reform
 
Pharmacognosy Flower 3. Compositae 2023.pdf
Pharmacognosy Flower 3. Compositae 2023.pdfPharmacognosy Flower 3. Compositae 2023.pdf
Pharmacognosy Flower 3. Compositae 2023.pdf
 
Employee wellbeing at the workplace.pptx
Employee wellbeing at the workplace.pptxEmployee wellbeing at the workplace.pptx
Employee wellbeing at the workplace.pptx
 
TataKelola dan KamSiber Kecerdasan Buatan v022.pdf
TataKelola dan KamSiber Kecerdasan Buatan v022.pdfTataKelola dan KamSiber Kecerdasan Buatan v022.pdf
TataKelola dan KamSiber Kecerdasan Buatan v022.pdf
 
Alper Gobel In Media Res Media Component
Alper Gobel In Media Res Media ComponentAlper Gobel In Media Res Media Component
Alper Gobel In Media Res Media Component
 

Exercise2 java

  • 1. Workshop 2 Q1. Write java program to manage fractions with addition, subtraction, multiplication and division. Q2. Vehicle Management System, including: car, motorbike, truck. Each of the Vehicle has attributes of manufacturer, manufacture year, cost, color. Moreover, cars have types of engine, number of seats. Motorbikes have power and trucks have load. Code a class named Car, Motor, Truck are directly derived from base class Vehicle object. Write a program with the following functions: 1. Input data of vehicles (validation data if necessarily) 2. To view the details of the vehicles (3 vehicles in one table or one for each table), to count the number of vehicles in the following table. 3. Searching by manufacturer, manufacture year, cost, color, types of engine, seats, … (exactly or approximately) 4. Searching from .. to…( manufacture year, cost) 5. Sorting by manufacturer, manufacture year, cost, color, types of engine, seats, … 6. To calculate statistics Q3. Library Management, including Book, Magazine, Newspaper. Each of the Document has attributes of code, publisher and circulation (tổng số phát hành). Moreover, Books have author, title and the number of pages. Magazines have issue number, monthly release. Newspapers have Release date. Code a class named Book, Magazine, Newspaper are directly derived from base class Document object. Write a program with the following functions: 1. Input data of documents (validation data if necessarily) 2. To view the details of all of documents (3 documents in one table or one for each table), to count the number of documents in the following table. 3. Remove, update for a document (enter a code of document) 4. Searching by code, publisher, circulation, author, title and the number of pages … (exactly or approximately) 5. Searching from .. to…( circulation, the number of pages, monthly release, Release date) 6. Sorting by code, publisher, circulation, author, title and the number of pages … 7. To calculate statistics Q4.
  • 2. One IT center requies full-time and part-time teachers. Full-time teacher information has teacher code, full name, email, Professor (Học hàm) (non, Prof. (Professor), Assoc. Prof. (Asscociate Professor), Assist. Prof. (Assistant Professor)), University degree (học vị) (Bachelor, Master, Post Doctor), address, phone, number of teaching hours per month, basic pay (lương cơ bản), pay rate (hệ số lương) (Bachelor: 1, Master: 1.1, Post Doctor: 1.2 and Prof. : +0.3, Assoc. Prof. +0.2, Assist. Prof. +0.1), Norm hour (số giờ định mức), overtime hour (50.000 vnd/1h). Part-time teacher information has teacher code, full name, email, Professor (non, Prof. (Professor), Assoc. Prof. (Asscociate Professor), Assist. Prof. (Assistant Professor)), University degree (Bachelor, Master, Post Doctor), address, phone, number of teaching hours per month, pay rate (Bachelor: 1, Master: 1.1, Post Doctor: 1.2 and Prof. : +0.3, Assoc. Prof. +0.2, Assist. Prof. +0.1), office, (200.000 vnd/1h). Write a program with the following functions: 1. Enter the information for full-time and part-time teacher (validation data if necessarily) 2. Display all teacher information (in one table or one for each table), to count the number of teachers in the following table. 3. Remove, update a teacher (enter code of teacher) 4. Searching by code, full name, email, Professor, Assoc. Prof., University degree, address, phone, number of teaching hours per month, basic pay, pay rate … (exactly or approximately) 5. Searching from .. to…( number of teaching hours per month, pay rate, …) 6. Sorting by code, full name, email, Professor, Assoc. Prof., University degree, address, phone, number of teaching hours per month, basic pay, pay rate … 7. To calculate statistics Q5. We have the design for Phone number: PhoneNumber - int area - String number + PhoneNumber() + PhoneNumber(int a, String n); + void display(); IntPhoneNumber - String countryCode
  • 3. + IntPhoneNumber () +IntPhoneNumber (String cc, int a, String n); + void display(); Implement the above classes and make your own main program to test all the above methods. The output of your program something look like: Enter list of phone numbers ----------------------------------------- Type of phone number ? (1 – local phone, 2 – Inter phone number, 0 - exit): 1 Enter area code: 111 Enter number: 111111 Type of phone number ? (1 – local phone, 2 – Inter phone number, 0 - exit): 2 Enter country code: 22 Enter area code: 222 Enter number: 222222 Type of phone number ? (1 – local phone, 2 – Inter phone number, 0 - exit): 1 Enter area code: 333 Enter number: 333333 Type of phone number ? (1 – local phone, 2 – Inter phone number, 0 - exit): 2 Enter country code: 44 Enter area code: 444 Enter number: 444444 Type of phone number ? (1 – local phone, 2 – Inter phone number, 0 - exit): 0 List of phone number: ---------------------------------------- 111 – 111111 22 – 222 – 222222 333 – 333333 44 - 444 – 444444 Note: You can using an array of base class PhoneNumber object
  • 4. PhoneNumber phonelist[] = new PhoneNumber[1000]; or ArrayList< PhoneNumber > phonelist = new ArrayList< PhoneNumber >(); Q6. We have the design for Staff:
  • 5. Person - String name + Person() + Person(String n) + void display(); + double getSalary(); Officer - double bSalary + Officer () +Officer (String n, double s) + void display(); + double getSalary(); - Person. getSalary() is an abstract method - Worker and Officer are subclasses of Person and Worker.salary = hrs * rate Implement the above classes and make your own main program to test all the above methods Add the below code to your main function and run Q7. Create a class named DictionaryWord as: DictionaryWord - word: String - meanings: String + DictionaryWord (String word, String meanings) + getWord(): String + setWord (String word): void + getMeanings(): String + setMeanings(String meanings): void Write a program with the following requirements: Creates 8 DictionaryWord objects with: ● Word and meanings as the table: Word Meanings bank robber Steals money from a bank Burglar Breaks into a home to steal things Worker - double hrs - final double RATE = 5.5 + Worker() +Worker(String n, double hrs) + void display(); + double getSalary();
  • 6. Forger Makes an illegal copy of something Hacker Breaks into a computer system Hijacker Takes control of an airplane Kidnapper Holds someone for ransom money Mugger Attacks and steals money from someone Murderer Kills another person ● Ensure that there is no duplicate DictionaryWord objects (02 DictionaryWord objects a and b are equal when a.word=b.word). Displays all DictionaryWord in ascending order of word with the format as: <<no>.<<word>> <<meanings>> <<no>.<<word>> <<meanings>> Where: <<no>>=1,2… Hint: ● class DictionaryWord implements Comparable to order 2 DictionaryWord objects. ● override equals(..) method to compare 2 DictionaryWord objects. ● override toString() ● use Set to ensure no duplicate. ● use support class Collections to sort DictionaryWord objects. Q8 : 1. Create a class Student includes name, age, mark and necessary methods. Using FileWriter, FileReader and BufferedReader to write a program that has functional menu: Menu ------------------------------------------------- 1. Add a list of Students and save to File 2. Loading list of Students from a File 3. Exit Your choice: _
  • 7. + Save to File: input information of several students and write that information into a text file, each student in a line (use tabs to separate the fields) + Read File: read and display information of students Accept a file name from users and display the content of entered file. Display the error message if that file does not exists.