Project #1: International Concurrency Converter

Submit: Turn in your money.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 1
 * Explain briefly the functionality of the program.
 * @author [your name]
 * Instructor [your instructor]
 * TA-BOT:MAILTO [your email address]
 */

Euros and Rupees and Yen, Oh My!

International Currency Converter

Whenever Lord Xinu (Dark Lord of the RISC) returns from an international business trip, he finds his pockets are full of international currency that cannot be used to purchase Raspberry Pi boards in the U.S.

Your task is to write a simple international currency converter. The converter will take an unformatted list of five allowable currencies, convert each to their equivalent in U.S. dollars, and print a final total when done.

Your converter should understand dollars ('$'), Euros ('€'), British pounds sterling ('£'), the Japanese Yen ('¥'), and the Indian Rupee ('₹').

You should use the getchar library function to read console input one character at a time. The use of any other library functions for input is not recommended at this time.

We have provided an example program for your reference, executable on Morbius as ~brylow/os/Projects/money.

Conversions

Conversion rates between international currencies change on a daily basis. For the sake of simplicity, we will use the rates that were in effect the day this assignment specification was written:

$1000 == £766 or €897 or ¥109940 or ₹70845.

You may assume that only integer values of currency will be entered, and no decimal points will appear in the input. Likewise, please use only integer arithmetic operations to perform your conversion, and output only truncated integer dollars. (Note that this means an answer of $0.99 is still just output as $0.)

Representation

The dollar sign ('$') is a regular ASCII character, a single byte in the system used nearly universally by computers to represent plain text. The other currency symbols, however, are all later additions to computer character sets. The Unicode Standard contains assignments for all of the currency symbols used in this project:

 

Table 1 Currency symbol codes
 
Symbol Unicode Meaning UTF-8 Encoding
$ U+0024 Dollar Sign0x24
£ U+00A3 Pound Sign0xC2, 0xA3
¥ U+00A5 Yen Sign0xC2, 0xA5
U+20AC Euro Sign0xE2, 0x82, 0xAC
U+20B9 Indian Rupee Sign0xE2, 0x82, 0xB9
 
* - All table values in hexadecimal

 

While all of these symbols can be represented by a simple two-byte encoding, the more common solution is to use a representation called UTF-8. This is the encoding actually used by Linux (as well as most web servers and e-mail clients) to store extended character values. The first 127 ASCII remain the same for reverse compatibility, but higher-numbered Unicode values are encoded with between two and four bytes.

What does all of this mean for you? When your program is reading or writing the currency symbols, you are actually going to use the byte combinations in the column marked "UTF-8" in Table 1 above.

Notes


[back]

[Revised 2020 Jan 16 00:56 DWB]