ICT167: Construct algorithms to solve Problems using a Combination of Sequence, Selection, and Iteration Constructs: Principles of Computer Science Homework, OU, Singapore

Submit your homework question & Get Plagiarism free Answers.

University The Open University (OU)
Subject ICT167: Principles of Computer Science

OBJECTIVES:

  • Construct algorithms to solve problems using a combination of sequence, selection, and iteration constructs.
  • Apply the Object-Oriented design paradigm to construct solutions in a modular way.
  • Implement such a design using the JAVA programming language.
  • Demonstrate a basic understanding of using an array.
  • Searching in the array of class objects.

Question This question reinforces concepts from Lab Practices I – S. Best practice ((Class and Method design, should be demonstrated. This will require a good understanding of class design concepts and method design concepts: code re-use, high cohesion, and low coupling. Before attempting this question, complete the pre-requisites listed on the first page of this document. For the assignment, I use a 0-0 design implemented in Java.

You will need to use a user-defined class, as an array of such class objects will be required.

Buy high-quality essays & assignment writing as per particular university, high school or college by Singapore Writers

User-defined Class:

You will design and implement your own data class. The class will store data that has been read as user input from the keyboard (see Getting Input below), and provide necessary operations. As the data stored relates to monetary change, the class should be named Change. The class requires at least 2 instance variables for the name of a person and the coin change amount to be given to that person.

You may also wish to use 4 instance variables to represent amounts for each of the 4 coin denominations (see Client Class below). There should be no need for more than these instance variables. However, if you wish to use more instance variables, you must provide a legitimate justification for their usage in the internal and external documentation.

Your class will need to have at least a default constructor, and a constructor with two parameters: one parameter being a name and the other a coin amount. Your class should also provide appropriate get and set methods for client usage.

Other methods may be provided as needed. However, make sure they are necessary for good class design; you must provide a legitimate justification for their usage in the internal and external documentation. In particular, your class should NOT include Input and Output methods.

The only way to get data out of a data class object to the client program is to use an appropriate get method. The data class methods must not write data out. Data should be entered into a data class object via a constructor or an appropriate set method.

Getting Input:

Input for the client program will come from the keyboard (entered by the user). The input should consist of: the name of a person, and a coin value (as an integer). The program should validate the input coin value to ensure that it is in the range of 5 to 95, and is evenly divisible by 5. Names are one-word strings. You should ask the user to enter the required information using a loop

with a question after each loop iteration to check if the user wants to end the input of data. It is recommended for the user to input at least 9 such data — this can be conveyed to the user using a message before entering the loop. NOTE: for the purpose of testing the program by your tutor, you should 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. In this case, your tutor would not need to manually key in the data to test the program when assessing your work. Thus, you should provide a call to this method (commented out) in the main function; this can be unconnected by your tutor as needed.

Example of inputs as follows:

Recommendation:

Please enter at least 10 records to test the program.

Please enter the name of the person:

Jane

Please enter the coin value for the person (range 5 to 95, multiple of 5):

30

Do you have more person to enter (YM):

Y

Please enter the name of the person:

John.

Please enter the coin value for the person (range 5 to 95, multiple of 5):

50

Do you have more person to enter (17N):

Please enter the name of the person:

Fred, Please enter the coin value for the person (range 5 to 95, multiple of 5):
94

Incorrect coin value. Must be in the range 5 to 95. and multiple of 5.

Please enter the name of the person:
Wilna

Please enter the coin value for the person (range 5 to 95, multiple of 5):
100

Incorrect coin value. Must be in the range 5 to 95, and multiple of 5.

Please enter the name of the person:
Jane,

Please enter the coin value for the person (range 5 to 95, multiple of 5):
35
Do you have more person to enter (11h1):
Y(assuming this is repeated at least 10 times)

Do you have more person to enter (YIN):

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 arc to utilize an army of Change objects. Do not use ‘ras List for this assignment. It should be noted that it is possible to have the come name entered numerous times. but the com 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 ova 100, 200, 300, or more cents. Make sure ton hare hank called test eases of the above fur your tutor to lest fur 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 com: spending to the coin amounts stored in the array of objects. Output change values must consist of the following denominations: SO cent, 20 cents, 10 cents, 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 the change to be given for each denomination

3. Find the name with the largest amount and display the change to be given for each denomination •. Calculate and display the largest number of coin denomination, and the total number of the coin

4. Exit
When the user enters the value I 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:

If the user enters a non-existent name Kg: Donald) at menu option I. which would therefore not be in the array of objects, your program will print:
Marne: Donald Not found

After processing the output for menu option I, 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 is having an 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 army 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 is having the 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 away 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 an 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: SO cent: 1 10 cent: 1 5 cent: 1
Customer: John 75 cent
Change: SO 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 cent

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.

The client program requires the submission of a structure chart. a high-level algorithm and low-level algorithm (i.e. suitable de-compositions of each step in the high-level algorithm).

Important Points: You need to provide a test plan to fully test your algorithm and program. As well as keyboard input. 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.

Your solution (user-defined class. client class program and algorithm) should be modular in design. For methods, use a high cohesion and low coupling design approach. These principles will also demonstrate good code re-use if done properly. Note that for this problem. the principle of code re-use is particularly important and a significant number of marks are allocated to this. You should attempt to design your solution such that it consists of a relatively small number of methods that are as general in design as possible, and you should have methods that code be re-used (called repeatedly)

in order to solve the majority of the problem (actual calculations). If you find that you have developed a large number of methods where each performs a similar task, OR there is a lot of code that is repeated in the methods, then attempt to analyze your design to generalize the logic so that you have just one general version of required methods.

Be mindful of the cohesion exhibited by a method. If you have a method that is doing more than one task, then cohesion is low, and you will need to re-design it to have high cohesion.

Distribution of marks for assessment

For the programming question. an approximate distribution of marks for assessment is given below. The question will be marked out of 100 as follows:

  • Correct solution design (class and method) and implementation. programming style (internal documentation (comments), use of methods, parameters, readability, presentation of output, etc.)
  • External l (problem specification, algorithm, program limitations, program listings, program test strategy, and test results. etc.):

For Intermit documentation (i.e. in the source code) we require:

  • A beginning comment clearly stating the title, author, date. file name. purpose and any assumptions or conditions in the form of input and expected output;
  • Other comments giving useful low-level documentation and describing each component (eg: method pre-and post-conditions);

Stuck with a lot of homework assignments and feeling stressed ? Take professional academic assistance & Get 100% Plagiarism free papers

Get Help By Expert

if you are not able to complete your (ICT167) Principles of Computer Science Homework then directly come to our experts and ask them to do my homework online. They will provide your high-quality assignment help with computer science assignments. Hire  Do My homework for money help services to get the best solution ICT167: Principles of Computer Science Homework.

Looking for Plagiarism free Answers for your college/ university Assignments.

Recent Solved Questions

Hire An Assignment Writer

Add More