CIS 261 C++ Programming

Program Requirements: Caesar's Census

Caesar has decreed that a census be taken. He has also decided that the results should be tabulated using the latest technology available: Census Meister MMV for Windows® XP. There is only one catch... it hasn’t been written yet. That fact has not slowed the marketing department one bit, in fact, they have already sold the product. It is up to you to write this software system, and to save your job... and our necks.

Input has been collected from the various provinces and consists of a text file containing the name of the province followed by the number of citizens (freemen) and slaves.

 SAMPLE INPUT FILE:

Gaul MCXVII    MMMCMCCXXI
Britannia CMDLVII  MMCMDCCLXVI
Rome MMMDCCXXV MMMMCMXXXVII
Pompeii IV XVI
Sicilia DCCXIV MDCLXVI

Input will come from an ASCII text file. Output should either be directed to the screen or to a file of the users choosing. 

Output should include appropriate headings, listing the provinces in descending order by total population, and totaling the number of citizens, slaves and a grand total.

Unfortunately the census bureau computers don’t recognize Roman Numerals! (Although in Rome they probably just called them numbers) Create a new data type roman using the class feature in C++. Overload the appropriate operators to allow input, output and basic math and relational operations on this new data type. Conversion routines to and from those newfangled Arabic numerals should be included as well. Create a separate class library for roman.

Hints:

This is actually two separate projects: a roman numeral class, and a straightforward file processing program.

 If the file processing program is coded first, using typedef roman int; will allow the entire program to be coded and tested separately from the roman class. (With a modified sample data file, of course.)

 

Deliverables

Use functional decomposition and modular programming techniques to divide the problem into appropriate functions.  NO GLOBAL variables are allowed.

Design: (25 points)

Problem Description
Algorithm
Data Structures (show the C++ code for how the data will be stored)
Functional Decomposition (showing structure and function headers)
Test Set Design

Final Program:

Working Arabic numbers version: Source Code & Sample Output (35 pts)

Working Roman numerals version: Source Code & Sample Output (40 pts)

BACKGROUND: 

http://www.gwydir.demon.co.uk/jo/roman/number.htm

All roman numbers are written from seven basic numerals.  These are:

I - 1

V - 5

X - 10

L - 50

C - 100

D - 500

M - 1000

There is no zero.  All other numbers are written by combining these seven symbols.

 

Roman numerals are written from left to right, using the principle of addition.  A person first writes the thousands, then the hundreds, then the tens, and finally the units.  Thus to write the number 2,763, a person first writes MM (2,000), then DCC (500+200=700), next LX (50+10=60) and finally III (3). 

The number 2,763 appears as MMDCCLXIII

 

All 4's and 9's use the principle of subtraction.  Thus 4 is written as IV, or 5 minus 1, and 9 is written as IX, or 10 minus 1.  The same principle applies to any number that begins with a 4 or 9, such as 40=XL, 90=XC, 400=CD, 900=CM.  In Roman numerals, a smaller numeral appearing before a larger numeral indicates that the smaller numeral is subtracted from the larger one.

                              [From: World Book Encyclopedia]