OBJECT ORIENTED DEVELOPMENT
IT213N
Laboratory 1
SESSION: AUG NOV 2019
Student Particulars
Name
:
IC Number
:
Student Number
:
Course Programme
:
DIIT
Intake
:
Subject Title
:
OBJECT ORIENTED DEVELOPMENT
Subject Code
:
IT213N
Assignment Title
:
LABORATORY 1
Name of Lecturer
:
MS GRACE TOK BEE CHOO
Due Date
:
5th NOVEMBER 2019, TUESDAY, 12PM
College
:
SEGI COLLEGE, PENANG
Declaration by student:
I, , hereby declare that the attached assignment is my own work and understand that if I am suspected of plagiarism or another form of cheating; my work will be referred to the lecturer who may, as a result recommend to the Examinations Board that my enrolment in the programme be discontinued.
Date Signature of student
Assignment Allocation of Marks
No.
Description of criteria
Weightings
Marks Allotted by Lecturer
1
Question 1
20
2
Question 2
20
3
Question 3
30
4
Question 4
30
Total Mark
100
Total Mark in 3
3
Comment:
Lecturers Name : Grace Tok Bee Choo
Date :
Learning Outcome Assessed
LO1
Applying the basic syntax for creating the HTML document.
LO2
Demonstrating new elements
LO3
Provide a high level of value added in terms of academic achievement and learning.
LO4
Apply the use of the principle focus that binds the concepts together, though all have relevance in the broader principles of Information Technology environment.
Description of Laboratory
Q1. Business Cards Limited is a company that designs and prints personal business cards. They have asked you to write a simple program using Java to provide personal business card information for a typical order. The format to be displayed is shown in the table below:
Write, Compile and test a Java program to print the table layout using your own personal information. Be sure to use good documentation principles for your program. Save the program as CardLayout.
Q2. Write a Java program to prints a conversion table of inches to meters. Display 5 inches of conversion, inch by inch.
Note: onemeter equals approximately 39.37 inches.
Q3. Write a program that calculates and display the amount of money you would have after 1year investment. Assume you have invested RM1, 000 at 3 percent interest for one month. Use the formula: Future Amount Principal Rate Principal.
Q4. Create an application that loops from 1 to 50 and prints out each value on a separate line, except print out hoo for every multiple of 3, haa for every multiple of 5, and haz for every multiple of 7.
Example:
1
2
3 hoo
4
5 haa
6 hoo
7 haz
8
9
10 haa
11
12 hoo
13
14 haz
15 hoo haa
.
.
.
Q5. Write a Java program that allows the user to do a number guessing from 1 to 100. Your program should base on the following conditions:
Generate a random number from 1 to 100.
Using IO Console, read an integer value from the user.
If the input value from the user matches the random number generated, display a message to congratulate the user and display the total number guessed by the user.
If the input value from the user does not match the random number generated, display the range lower limit and upper limit of the random number it should be.
The guessing process should be continuing until the user successfully guessed the number.
Hint: Math.random used to returns a double value with a positive sign, greater than or equal to 0.0 and less than 1.0
Example:
Q6. A palindrome is a sequence of characters that reads the same backwards as forward. For example, each of the following fivedigit integers is a palindrome: 12321, 55555, 45554 and 11611. Write an application that reads a fivedigit integer and determines whether it is a palindrome. The program will display an error message if the number is not five digits long.
Q7. Write a program that requires the user to enter the month and year of a date. The program will display the number of days in the given month. For example, if the user entered month as 2 and year as 2000, the program should display that February 2000 has 29 days. If the user entered month as 3 and year as 2005, the program should display that March 2005 has 31 days.
Q8. Write a program that stores vowels a, e, i, o and u in an array. The program will ask the user to enter a character. Then the program should indicate whether the entered character is a vowel.
Q9. Write a program that will allow a user to compute his or her average exam marks and the grade obtained. The program will request the user to input marks of three different subjects. Then it will calculate the average marks. The average marks will be used to determine the grade for the user based on the condition below:
Average Mark
Grade
Message to be displayed
70 to 100
A
Well Done!
55 to 69
B
Good!
40 to 54
C
You can do better.
0 to 39
F
Study hard. Better pass next time.
Finally, the average mark, grade obtained, and a short message will be displayed on the screen as follows:
Q10. Write a class named Planet, which contains two instance variables that store the name of a planet and the number of days a planet takes to travel around the Sun. Provide the set and get methods for each instance variables, and an additional method named calculateAge to calculate your age on that planet. The calculateAge method should receive an argument that represent your age on Earth. x 365 travel days of a planet.
Q11. Write a test class that inputs the users Earth age and print outs this or her age on Mercury, Venus, Jupiter and Saturn.
Q12. Write a program that displays an invoice of several items. It should contain the item name, quantity, price and total cost on each line. Use two classes. The first class contains the data items and methods to get and set the items name, quantity and price. The other class creates objects for the items and uses the objects to call the set and get methods. Save the program as Invoice.java.
Q13. Create a class named Numbers whose main method holds two integer variables. Assign values to the variables. Create two additional methods, sum and difference, that compute the sum of and difference between the values of the two variables, respectively. Each method should perform the computation and display the results. In turn, call each of the two methods from main, passing the values of the two integer variables. Save the program as Numbers.java.
a Add a method named product to the Number class. The product method should compute the multiplication product of the two integers, but not display the answer. Instead, it should return the answer to the calling main program, which displays the answer. Save the program as Numbers.java.
Q14
a Creating the Country class
Write a class called Country that represents countries in the world. Each Country object has data items name and population data member. All countries have a leader, either a president or prime minister. The name of the leader data member is also stored in a Country object.
Include the methods listed below for Country class:
Constructor with parameters
Accessor getmethods for all data fields
Mutatorset methods for all data fields
Compile the Country class.
b Writing the CountryWithRoyalty subclass class
Some countries have royal rulers kings or queens as well. Write a subclass named CountryWithRoyaltyclass name to represent these countries. Objects of this class include a royal ruler name.
Include the methods listed below for CountryWithRoyalty class:
Constructor with parameters
Accessor methods for all data fields
Mutator methods for all data fields
Compile the countryWithRoyalty class.
c Writing the demo class
Write a demo class to test the two classes you have written. Create 1 object for each class, and then display all the details in each objects.
Q15
XXX Airlines is recruiting airline staffs. An airline staff should have a name and an ID. In addition, a steward should have a fitness score and a stewardess should have a communication score. The basic salary for an airline staff is RM2000. Calculation of salary for steward and stewardess is different, as shown below.
For steward salarybasic salaryfitness score10;
For stewardess salarybasic salarycommunication score10
Create the classes in the inheritance hierarchy as shown in the figure below. Each class should have appropriate constructors, set methods and get methods. Write a program that instantiates object of each of these classes and outputs all information associated with each object including inherited information. SHAPE MERGEFORMAT
Q16
Provided the Employee Inheritance hierarchy above, construct an inheritance program to calculate the pay for each type of employee respectively. Encapsulation principle should be applied along the program to hide employee info.
Payment Method for each type of employee
SalariedEmployee
WeeklySalary TotalWeekInAMonth
CommissionEmployee
GrossSales CommissionRate100
HourlyEmployee
Total Hour worked in the month AmountPerHour
BasedPlusCommissionEmployee
BaseSalary GrossSales CommissionRate100
An Employee should have a first name, last name and socialsecurity number. In addition, a SalariedEmployee should have a weekly salary; A HourlyEmployee should have a wage and number of hours worked; a CommissionEmployee should have a commission rate and gross sales; and a BasePlusCommissionEmployee should have a base salary.
Construct a TestEmployee class program Caller to test the EmployeeClass. Request necessary data from user, calculate and display out the total pay for the user.
Q17
Generate the output below:
Create the interface below using code instead of dragging and dropping from the properties. It consists of four main buttons which perform different calculation and cancel button to clear the text field.
Create the interface below. The operation combo box consists of four choices which are addition, subtraction, division and multiplication. The calculation will be performed according to the choices when the button is clicked.
Q18
Complete the following program:
Design an application for a pizzeria. The user makes pizza order choices from the list boxes, and the application displays the price according to the order choices. The user can choose a pizza size of small RM7, medium RM9 and large RM11 and one of any number of the toppings. There is no additional charge for cheese, but any other topping adds RM1 to the base price. Offer at least five different topping choices. Save the file as Pizza. Java.
Question 3
Create the registration form below:
Registration Successfully will be shown when Submit button is clicked.
Details will be shown in the text area on the right.
Please create all the components by using code instead of dragging and dropping from the properties.
The terms and conditions checkbox must be ticked in order to proceed. Error message will be shown on a label if the checkbox is not checked.
Q19
Create a Java Application called GUIDBConnection. Create a JFrame file called VideoPlayer.java. Design the interface below in the JFrame file.
Q20
Create another JFrame file called CheckLibrary.java. Design the interface below.
Procedures as below:
The user will enter the video number in the text field.
Once the List All Videos button is clicked, all the video details will be listed as below in the text area. You may display number for the rating
Create a database with the following data fields:
Data Field
Data Type
ID
Number
Rating
Number
Play Count
Number
Video Name
Short Text
Director
Short Text
Q21
When the Check Video button is clicked, the following GUI will be shown:
Missed out any of the above format, each will be deducted one mark from the total marks of your assignment
Please only submit your soft copy of lab practical attached with the cover page before or on 5th November 2019, Tuesday, 12pm to your lecturer. All coursework should be submitted on the scheduled dateline. Extensions are not normally granted but in exceptional cases, limited extensions may be granted.
In term of late submission, a 10 deduction per day of total coursework marks excluding weekends and public holidays. Late submission between 5 to 10 days will deduct a 50 of the total coursework marks. Late submission past 10 days and nonsubmission will result in an automatic 0 for the coursework.
Prepared by: Grace Tok Bee Choo
Assignment Submission Date:
5th November 2019, Tuesday, 6pm
First Name Last Name
Address 1
Address 2
Zip code, City, State
Home Phone
Work Phone
EMBED PBrush
Sample run:
Please enter mark for subject 1: 80
Please enter mark for subject 2: 60
Please enter mark for subject 3: 70
The average is 70.
You have obtained Grade A. Well Done! Keep your good work.
AirlineStaff
Steward
Stewardess
Employee
First, last name,
Social security number
SalariedEmployee
CommissionEmployee
HourlyEmployee
BasePlusCommission
Employee
SEGI COLLEGE PENANG
IT213N OBJECT ORIENTED DEVELOPMENT
Laboratory 1