Assignment 2 uses structured design implemented in C. Array of records (structs) with file I/O is needed. The program takes two inputs at a time. The name of a person, and, the coin value as an integer in the range 5 to 95. Input coin values should always be divisible by 5 (integer division). Names are one word strings. An example input is: Jane 30 This input line indicates that 30 cents change is to be given to Jane. Output change values need to be in multiples of 50, 20, 10 and 5 cents. 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. A better solution is to give a 20 cent coin and a 10 cent coin. Page 4 of 10 Input to the program comes from a data file called coins.txt. There can be 0 and up to 10 input lines like the example above. It is also possible to have the same name repeated in the data file but the coin values can be different. When the name is the same, it would mean the same individual. If the name is the same, your program would need to add up the coin amounts to obtain a total amount for that individual before computing the change to be given.
Assignment 2 uses structured design implemented in C. Array of records (structs) with file I/O is needed.
The
This input line indicates that 30 cents change is to be given to Jane. Output change values need to be in multiples of 50, 20, 10 and 5 cents. 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. A better solution is to give a 20 cent coin and a 10 cent coin.
Page 4 of 10
Input to the program comes from a data file called coins.txt. There can be 0 and up to 10 input lines like the example above. It is also possible to have the same name repeated in the data file but the coin values can be different. When the name is the same, it would mean the same individual. If the name is the same, your program would need to add up the coin amounts to obtain a total amount for that individual before computing the change to be given.
Trending now
This is a popular solution!
Step by step
Solved in 3 steps with 2 images