Project #2: The Virtual Money Pile

Submit: Turn in your moneypile.c source file using the turnin command on morbius.mscsnet.mu.edu or one of the other Systems Lab machines.

Work is to be completed individually. Be certain to include your name in the file. You may submit multiple times, but only the last turnin will be kept. The automatic submission system will not accept work after the deadline. (See turnin instructional video HERE. Note that the video is for a different course number, and that Morbius's domain name has changed since the video was made: morbius.mscs.mu.edu -> morbius.mscsnet.mu.edu)

Include a comment block at the very top of each file that contains the following:

/**
 * COSC 6270 - Project #
 * Explain briefly the functionality of the program.
 * @author [your name]
 * Instructor [your instructor]
 * TA-BOT:MAILTO [your email address]
 */

Currency Caching

The Virtual Money Pile

Lord Xinu (Dark Lord of the RISC) is pleased by your progress in helping him to convert his vast sums of loose, multi-national pocket change into U.S. Dollars, but now requires help with a different task.

As donations stream in from grateful open source embedded systems developers from around the globe, Lord Xinu's minions must sort the currency as it arrives according to type. Being a stickler for queuing behavior, Lord Xinu demands that the money on the bottom (first in) be the last to be logged in his ledger (last out), each according to its currency.

You are to construct a virtual money pile, which tracks each donation as it is placed in a pile with like currency, and then reads each pile of currency back out in reverse order.

The Program

Write a C program that reads in an arbitrarily long sequence of positive integer currency values (in the style of Project 1), and outputs each category of currency in reverse order.

Your converter should understand dollars ('$'), Euros ('€'), British pounds sterling ('£'), the Japanese Yen ('¥'), and the Indian Rupee ('₹'). This should reuse code from your previous project.

Your program should ignore any amount of white space between currency values, including tabs, spaces, newlines, etc. See the isspace() function in your text or in the man pages for details. However, your output should place each currency value on a line by itself.

When the end of input ("EOF") is reached, the piles should be printed in order of dollars, British pounds sterling, Japanese Yen, Euros, and finally Indian Rupees.

To store an arbitrary list of integers, your program will need to request more memory from the operating system when the space it already has runs out. This kind of dynamic allocation is performed using the malloc() function, as detailed in your text and in the man pages. You may assume that we will test your program with at least 100,000,000 integers. Your program should exit gracefully if a malloc() request is denied.

The professor has provided an example program for your reference, executable on all lab machines as ~brylow/os/Projects/moneypile. In addition, there is a test generator executable as ~brylow/os/Projects/randomcurrency. The test generator takes a single command-line parameter for the number of values desired, and then outputs a predictable sequence of pseudo-random numbers [Wikipedia] using a linear congruential generator [Wikipedia] and rotating through the various currencies.

Notes


[back]

[Revised 2020 Jan 22 11:36 DWB]