Reference no: EM133364994
Question One
You should complete this question in week one.
Your activity is to complete the QuestionOne class. In the class, you must:
Have at least four instance variables of different data types, with at least one primitive and one wrapper.
Make use of constructor overloading i.e. Have more than one constructor.
Have accessor (getter) and mutator (setter) methods for ALL instance variables.
Have a method that prints the contents of all of the instance variables. The output must be formatted for readability. For example if you have an instance variable called age that has a value of 7 you might print something like The age is 7.
Have a method with an if-else statement that takes uses the value of one of the instance variables in the condition and prints a message based upon the value.
You must complete the following in the main method:
Demonstrate the use of all of your constructors i.e. use each constructor in the class to create a QuestionOne object.
Demonstrate the use of an accessor method i.e. use one of the accessor methods from one of the objects you just created.
Demonstrate the use of an mutator method i.e. use one of the mutator methods from one of the objects you just created. .
Demonstrate the use of the method that prints the contents of all of the instance variables i.e. use the print method from one of the objects you just created.
Demonstrate the use of the method with the if-else statement i.e. use the method with the if-else statement from one of the objects you just created.
Make sure you:
Add class comments, with your name as author and date as the last date you worked on this exercise.
Add comments to describe the instance variables and methods in the class.
Name all variables and methods as per Java naming conventions.
Question Two
You should start this question in week one and finish it in week two.
Your activity is to complete the QuestionTwo class. In the class, you must:
Declare an Array of data type double and insert at least five values to the Array.
Loop through the Array and for each element (double value that you inserted) in the Array, print the following formatted for readability:
The index of the element.
The absolute value of the element (hint - you will need to use one of the methods from the Math class covered in module 1).
The value of the element rounded up to its nearest integer (hint - you will need to use one of the methods from the Math class covered in module 1).
The value of the element rounded down to its nearest integer (hint - you will need to use one of the methods from the Math class covered in module 1).
The square root of the element (hint - you will need to use one of the methods from the Math class covered in module 1).
The result and remainder when the element is divided by the number of elements in the Array i.e. an int that is equal to the size of the Array (hint - you will need to use the division and modulus operators covered in module 1).
Please note that the above must print when the main method runs. How you do this is up to you. You can write all of the code in the main method for this question if you like.
Make sure you:
Add class comments, with your name as author and date as the last date you worked on this exercise.
Add comments to describe the instance variables and methods in the class.
Name all variables and methods as per Java naming conventions.
Question Three
You should start this question in week two.
Your activity is to complete the QuestionThree class. In the class, you must:
Declare an Array of data type String as an instance variable.
Initialize the Array. Generate a random number and use the random number as the Array size. You do not need to add elements to the Array when initializing it (hint - you can do this in the constructor. Generating random numbers is covered in module 1. If you can not do this then you can give the array a size of your choosing).
Have a method that takes a parameter and adds the parameter to the Array. A suitable error message must be given if the Array is full.
Have a method that sorts the Array.
Have a method that prints all of the elements in the Array.
Using the methods that you wrote, you must do the following in the main method:
Create an object of type QuestionThree.
Use the method that you wrote to add at least five elements to the Array.
Use the method you wrote to print all of the elements in the Array.
Use the method you wrote to sort the Array.
Use the method you wrote to print all of the elements in the Array again to demonstrate that the sort method you wrote successfully sorted the Array.
Make sure you:
Add class comments, with your name as author and date as the last date you worked on this exercise.
Add comments to describe the instance variables, and methods.
Name all variables and methods as per Java naming conventions.