I need the source code for this question 4 in Java. Please provide an explanation for the methods provided. Client Class: The client program should read the input data from the user (or the method with hardcoded inputs) and use the Change class to store the data entered. This data should be stored in a Change class object. You will need a data structure to store the Change class objects according to the number of persons entered. Thus, you are to utilize an array of Change objects. Do not use ArrayList for this assignment It should be noted that it is possible to have the same name entered numerous times, but the coin values for such repetitions could be different. When the name is the same, it would mean the same individual, and your program should add up the coin amounts to obtain a total amount for that individual; this should be performed before computing the change to be given. Note that in this scenario, the total amount for an individual may end up being over 100, 200, 300, or more cents Make sure you have hardcoded test cases of the above for your tutor to test for these situations. Processing would involve determining repeated names and accumulating the total for those repeated names. You must ensure that there are no objects with repeated names in the array. Then methods would need to be called to calculate the required output corresponding to the coin amounts stored in the array of objects. Output change values must consist of the following denominations: 50 cent, 20 cent, 10 cent and 5 cent coins. The program should aim to give as much of the higher valued coins as possible. A poor solution for an input of 30 cents is to give six 5 cent coins. The better solution is to give a 20 cent coin and a 10 cent coin Once the data input has been completed, your program should then display a menu screen as illustrated below. The program will continue to show the menu and execute the menu options until "Exit" is selected by entering the value 5 at the menu prompt
I need the source code for this question 4 in Java. Please provide an explanation for the methods provided.
Client Class:
The client program should read the input data from the user (or the method with hardcoded inputs)
and use the Change class to store the data entered. This data should be stored in a Change class
object. You will need a data structure to store the Change class objects according to the number of
persons entered. Thus, you are to utilize an array of Change objects. Do not use ArrayList for this
assignment
It should be noted that it is possible to have the same name entered numerous times, but the coin
values for such repetitions could be different. When the name is the same, it would mean the same
individual, and your program should add up the coin amounts to obtain a total amount for that
individual; this should be performed before computing the change to be given. Note that in this
scenario, the total amount for an individual may end up being over 100, 200, 300, or more cents
Make sure you have hardcoded test cases of the above for your tutor to test for these situations.
Processing would involve determining repeated names and accumulating the total for those repeated
names. You must ensure that there are no objects with repeated names in the array. Then
methods would need to be called to calculate the required output corresponding to the coin amounts
stored in the array of objects. Output change values must consist of the following denominations:
50 cent, 20 cent, 10 cent and 5 cent coins. The program should aim to give as much of the higher
valued coins as possible. A poor solution for an input of 30 cents is to give six 5 cent coins. The
better solution is to give a 20 cent coin and a 10 cent coin
Once the data input has been completed, your program should then display a menu screen as
illustrated below. The program will continue to show the menu and execute the menu options until
"Exit" is selected by entering the value 5 at the menu prompt
1. Enter a name and display change to be given for each denomination
2. Find the name with the smallest amount and display change to be
given for each denomination
3. Find the name with the largest amount and display change to be
given for each denomination
4. Calculate and display the largest number of coin denomination,
and the total number of the coin
5. Exit
When the user enters the value 1 at the menu prompt, your program will ask for a name. As an
example, if the user enters the name Jane (as in the example input above), the program will output:
Customer:
Jane 165 cent
Change:
50 cent: 3
10 cent: 1
5 cent: 1
N.B. change values of 0 are not shown for screen output.
If the user enters a non-existent name (eg: Donald) at menu option 1, which would therefore not be
in the array of objects, your program will print:
Name: Donald
Not found
After processing the output for menu option 1, the menu is re-displayed.
When the user enters 2 at the menu prompt, your program will search all objects in the array to find
the object with the smallest coin amount. Then the program will output the name for the person, and
the denomination breakdown of their change. If there is more than one person who are having equal
smallest coin amount, just return the first person found in the array. After processing the output for
menu option 2, the menu is re-displayed.
When the user enters 3 at the menu prompt, your program will search all objects in the array to find
the object with the largest coin amount. Then the program will output the name for the person, and
the denomination breakdown of their change. If there is more than one person who are having equal
largest coin amount, just return the first person found in the array. After processing the output for
menu option 3, the menu is re-displayed.
When the user enters 4 at the menu prompt, your program will access all objects in the array to
calculate and display only the largest number of coin denomination, and the total number of coins
for the largest denomination. If there are more than one coin denominations having equal amount,
you will need to list down all of them. After processing the output for menu option 4, the menu is
re-displayed.
For example:
Customer:
Jane 65 cent
Change:
50 cent: 1
10 cent: 1
5 cent: 1
Customer:
John 75 cent
Change:
50 cent: 1
20 cent: 1
5 cent: 1
Menu option 4 should return as follows.
The largest number of coin denomination is:
50 cents
5 cents
The total number of 50 cent coin is: 2
The total number of 5 cent coin is: 2
When the user enters 5 at the menu prompt, your program will write an appropriate farewell message
to screen and exit.
Important Points:
You need to provide a test plan to fully test your
do not forget to provide a method in the client class that hardcodes data into at least 10 Change
objects and stores these objects into the array provided by your program. Think carefully about how
to construct this test data. If done well, you should be able to do nearly all required testing with this
set of test data.
Trending now
This is a popular solution!
Step by step
Solved in 4 steps with 3 images