Create a class named Customer that will determine the monthly repayment amount due by a customer for a product bought on credit. The class has five fields: customer name, contact number, product price, number of months and the monthly repayment amount. Write get and set methods for each field, except for the monthly repayment amount field. The set methods must prompt the user to enter the values for the following fields: customer name, contact number, product price and number of months. This class also needs a method to calculate the monthly repayment amount (product price divided by the number of months).
Write the following generic method using selection sort and a comparator: public static <E> void selectionSort(E[] list, Comparator<? super E> comparator) Write a test program that creates an array of 10 GeomtricObjects and invokes this method using GeometricObjectComparator introduced in Listing 20.5 to sort the elements. Display the sorted elements. Use the following statement to create the array: GeometricObjectfi list1 = {new Circle(5), new Rectangle(4, 5), new Circle(5.5), new Rectangle(2.4, 5),
new Circle(0.5), new Rectangle(4, 65), new Circle(5.4), new
rectangle(6.6,1),
new Circle(5.6), new rectangle(5, 4); Also in the same program, write the code that stores six strings by their last character. Use the follwing statement to create the array: String 0 list2 = {"red", "blue", "green", "orange", "yellow", "pink")
You have to design your own Java console application about any valid problem that your application must solve. Your solution can include solving a business problem, a new idea or even a game. Your application must make use of concepts such as arrays, loops, inheritance, constructors and information hiding. Output must be shown in the form of a report using the console.
In your solution, make use of as many concepts, and components dealt with in this course, but pay special attention to the following learning units: • Learning Unit 1: Advanced arrays. • Learning Unit 2: Introduction to inheritance.
The statements below shows the declaration of an array:
String[] Municipality ={”Steve Tshwete”, “Nkomazi”, “City of Mbombela”, “Govan Mbeki”};
1) Make use of a loop of your choice and write statement(s) that will display all array elements indicating the Municipality’s name as follows:
Municipality 1: Steve Tshwete
Municipality 2: Nkomazi
Municipality 3: City of Mbombela
Municipality 4: Govan Mbeki
1) Write a statement that will replace array element Nkomazi with White River.
3) What is the array length?
4) Make use of a loop of your choice and write statement(s) that will display all Municipalities, considering effects of question (2), starting with the last Municipality as shown below:
Municipality 4: Govan Mbeki
Municipality 3: City of Mbombela
Municipality 2: Nkomazi
Municipality 1: Steve Tshwete
Define Exception Handling. Write a java program to create a user defined
exception for the following
a) Create a student class and get the name of the student and 3 subject marks
b) Find the length of the name. If the length > 7 throw LengthException
c) Find the average of marks, if avg < 50 throw FailedException
d) If avg < 75 && avg > 50 throw NotFirstClassException
e) If avg > 75 throw FirstClassException
Create a program that when run with two numbers as CMD arguments, it prints out the difference
and product separated by space[Hint: CMD arguments need to be converted to integers]:
Sample run 1:
java lab02_task02 12 3
Output: 9 36
Sample run 2:
java lab02_task02 2 5
Output: -3 10