CSC210C++ Name: ______
Lab 1: Roman Numeral Class*Rev ASignature: ______
Due Date: September 17, 2018 (evening class) (has neither given nor received aid on this program)
September 11, 2018 (afternoon class)
Purpose: The purpose of this lab is to familiarize students with an Object Oriented C++software environment, creating class files, and to make students more comfortable in writing and submitting programs via email. The class has a function to convert roman numerals to valid decimal numbers (otherwise -1).
Problems:
- Install the CodeBlocks Compiler and IDE on your home computer.
- The basic directions are found in Programming Exercise 4, in Chapter 10, p. 730-731. However, this program is non-interactive (no keyboard inputs). Instead, all input data will be read in from a string array in the “client” code. Additionally, you should make two files: romanTester.cpp (“client” code with functions to create class objects and call class functions) andromanType.cpp (class implementation file with all functions defined). The RomanType.h (header file specificationsare given without your alteration). Your implementation signatures must use the exact header file’s names for each function. The algorithmfor converting the roman numeral to a decimal will be extensively discussed in class.
- Your romanTester.cppclient should store these12 example roman numerals in the romanTester’s string array. Your class constructor shouldinitialize myRoman and call the class function makeDecimal() to assign its private member: myDecimal.
- Instantiate a default object, display its values, test your setRoman function with the first array element, display its values, then construct each remaining string array element asinput, and display its values. The class functionmakeDecimal()will translate eachroman numeral stringinto its equivalentdecimal number. The printRomanDecimal() function will output each line of roman numeral and decimal equivalent neatly centered below its subtitles.
- Call client functions in the romanTesterto keep the main function small and clean. Make a title function to include your name in the output. The exact output format is totally up to you. However, the output should include all items in the example neatly aligned with elements centered and very neatly formatted (right justified). Send the same information to the console and the captured output file (echo printing) by using your class function printRomanDecimal(fout).
.
- Please email me the following files from onlyyour TCC email account to:
romanTester.cpp (“client” contains the main function)
RomanType.cpp (contains the class implementation)
RomanType.h (contains the class prototypes)
romanOutput.txt (contains the captured output of your program’s 13 conversions)
- Attach thesefour files to your email message and put CSC 210Lab1 as the subject of the email before the due date.
- Print hard copies of each of the 4 files (above) plus the completed homework problems listed below. Staple all printouts below this specification sheet.
- Homework: Write answers (only) to the following:pp. 720-723Chapter 10: Exercises 1 through 8. Note: Odd # questions are in the back of book.
Checklist:
Staple these required itemsin this order: (1) this signed specification sheet, (2)romanTester.cppclient file, (3) romanType.cpp (implementation) file,(4) romanType.h(header specifications) file, (5) your romanOutput.txt file (created by your program), and (6) your homework (answers only).
Please, do not hesitate to seek my help in this lab assignment.Ask many questions in class.
/* RomanType.h
Written by Jeff Goldstein, TCC Adjunct Professor, VB Campus
Updated 07/22/2018
Header file (Specifications for the RomanType class)
Conditions: a Roman Numeral is a string input (such as MCMXVII)
The class will convert the roman numerals to a decimal number (such as 1917)
This file must not be altered. Each of these functions should be implemented.
*/
#ifndef ROMAN_TYPE_H
#define ROMAN_TYPE_H
class RomanType
{
public:
RomanType(string s = "M");// constr. w/ one default string parameter
~RomanType();// destructor
//RomanType(const RomanType & );// copy constructor (done in future Labs)
int getDecimal() const;// returns the private field myDecimal;
string getRoman() const; // gets the private field myRoman
void setRoman(string);// sets the private field myRoman
void printRomanDecimal(ofstream &) const; // echo prints roman numeral & decimal
int makeDecimal() const;// converts myRoman to myDecimal
private:
string myRoman;// private fields for the roman numeral
int myDecimal;// private field converted as decimal
};
#endif // ROMAN_TYPE_H
------
R O M A N N U M E R A L C O N V E R T E R
by
Jeff Goldstein
Numeral Decimal
------
M 1000
MMIC 2099
MCIX 1109
MCXLIV 1144
MMXVIII 2018
MDCLXVI 1666
CDXCIX 499
CCCLIX 359
DCCIV 704
MIXIT -1
NOWAY -1
MOM -1
DAD -1
(note: -1 indicates an error decoding this roman numeral)