Professional Documents
Culture Documents
Question 1
Create a class called MultiplicationTable
Information Stored
a) The multiplication number, e.g.:
a. 3 for multiplication tables of 3
b. 7 for multiplication tables of 7
b) The range from, e.g.
a. 13 for the multiplication tables of 3 from 13 to 27
b. 71 for the multiplication tables of 7 from 71 to 100
c) The range to, e.g.:
a. 27 for the multiplication tables of 3 from 13 to 27
b. 100 for the multiplication tables of 7 from 71 to 100
Methods Included
i) A method or set of methods to set the information to the data stored.
ii) A method printTable() that when called, will print the multiplication tables of the
multiplication number from the range from to the range to
iii) The method main(String args[]) in which you create 3 objects of type Multiplication
Tables with the details outlined in the table below. Each object should then be told to
print its own multiplication tables by calling the method printTable() for each.
Page 1 of 4
Question 2
Concepts Tested
1. If statements
2. For loops
3. Classes and objects
4. Execution of a Java program in Netbeans
Exercise
public static void main(String args[]){
Page 2 of 4
Instructions
1. Create the class definition for YearRange and determine its data members and methods.
2. Create another class in which you have the main method outlined above.
3. The hints of the data members and methods required for YearRange are included in the
main method above.
Question 3
Create a class called Building
Information Stored
Methods Included
Expected Output
Using the class you have defined, create an array that can hold 5 buildings. Populate this array with
5 buildings, having assigned each its details.
Using a loop through the array, print out a report such as the one below.
//Print out
-----Start of Report--------------
<<Name of building 1>> is a <<colour of building>> and has <<number of rooms>> rooms.
Page 3 of 4
<<Name of building 3>> is a <<colour of building>> and has <<number of rooms>> rooms.
<<Name of building 4>> is a <<colour of building>> and has <<number of rooms>> rooms.
<<Name of building 5>> is a <<colour of building>> and has <<number of rooms>> rooms.
------End of Report-------
Page 4 of 4