Write a program that convert number entered in roman numeral

Assignment Help Programming Languages
Reference no: EM131135883

1. Write a program that converts a number entered in Roman numerals to decimal form. Your program should consist of a class, say romanType. An object of romanType should do the following: a. Store the number as a Roman numeral. b. Convert and store the number into decimal form. c. Print the number as a Roman numeral or decimal number as requested by the user. (Write two separate functions-one to print the number as a Roman numeral and the other to print the number as a decimal number.) The decimal values of the Roman numerals are: M 1000 D 500 C 100 L 50 X 10 V 5 I 1 Remember, a larger numeral preceding a smaller numeral means addition, so LX is 60. A smaller numeral preceding a larger numeral means subtraction, so XL is 40. Any place in a decimal number, such as the is place, the 10s place, and so on, requires from zero to four Roman numerals. d. Test your program using the following Roman numerals: MCXIV, CCCLIX, and MDCLXVI.

2. Write the definition of the class dayType that implements the day of the week in a program. The class dayType should store the day, such as Sunday for Sunday. The program should be able to perform the following operations on an object of type dayType: a. Set the day. h. Print the day. c. Return the day. d. Return the next day. e. Return the previous day. f. Calculate and return the day by adding certain days to the current day. For example, if the current day is Monday and we add 4 days, the day to be returned is Friday. Similarly, if today is Tuesday and we add 13 days, the day to be returned is Monday. g. Add the appropriate constructors. -

3. Write the definitions of the functions to implement the operations for the Class dayType as defined in Programming Exercise 2. Also, write a program to test various operations on this class.

4. In this chapter, the class dateType was designed to implement the date in a program, but the member function setDate and the constructor do not check whether the date is valid before storing the date in the data members. Rewrite the definitions of the function setDate and the constructor so that the values for the month, day, and year are checked before storing the date into the data members. Add a function member, isLeapYear, to check whether a year is a leap year. Moreover, write a test program to test your class.

5. In Programming Exercise 2, the class dateType was designed and implemented to keep track of a date, but it has very limited operations. Redefine the class dateType so that it can perform the following operations on a date in addition to the operations already defined: a. Set the month. b. Set the day. c. Set the year. d. Return the month. e. Return the day. f. Return the year. g. Test whether the year is a leap year. h. Return the number of clays in the month. For example, if the date is 3-12-2011, the number of days to be returned is 31 because there are 31 days in March. I. Return the number of days passed in the year. For example, if the date is 3-18-2011, the number of days passed in the year is 77. Note that the number of days returned also includes the current day. 126 I Chapter 2: Object-Oriented Design (00D) and C++ I. Return the number of days remaining in the year. For example, if the date is 3-18-2011, the number of days remaining in the year is 288. k. Calculate the new date by adding a fixed number of days to the date. For example, if the date is 3-18-2011 and the days to be added 'are 25, the new date is 4-12-2011.

6. a. In Programming Exercise 1 in Chapter 1, we defined a class romanType to implement Roman numerals in a program. In that exercise, we also implemented a function, romanToDecimal, to convert a Roman numeral into its equivalent decimal number. Modify the definition of the class romanType so that the data members are declared as protected. Use the class string to manipulate the strings. Furthermore, overload the stream insertion and stream extraction operators for easy input and output. The stream insertion operator outputs the Roman numeral in the Roman format. Also, include a member function, decimalToRom'en, that converts the decimal number (the decimal number must be a positive integer) to an equivalent Roman numeral format. Write the definition of the member function decimalToRoman. For simplicity, we assume that only the letter I can appear in front of another letter and that it appears only in front of the letters v and X. For example, 4 is represented as IV, 9 is represented as Ix, 39 is represented as xxxix, and 49 is represented as xxxxix. Also, 40 will be represented as XXXX, 190 will be represented as CLXXXX, and so on. b. Derive a class extRomanType from the class romanType to do the following. In the class extRomanType, overload the arithmetic operators +, *, and / so that arithmetic operations can be performed on Roman numerals. Also, overload the pre- and postincrement and decrement operators as member functions of the class extRomanType. To add (subtract, multiply, or divide) Roman numerals, add (subtract, multiply, or divide, respectively) their decimal representations and then convert the result to the Roman numeral format. For subtraction, if the first number is smaller than the second number, output a message saying that, "Because the first number is smaller than the second, the numbers cannot be subtracted". Similarly, for division, the numerator must be larger than the denominator. Use similar conventions for the increment and decrement operators. c. Write the definitions of the functions to overload the operators described in part b. d. Write a program to test your class extRomanType.

Reference no: EM131135883

Questions Cloud

What is the duration of the bond : You purchase a $100 face value U.S 10%, 30-year bond for $110. What is the duration of the bond. what is the current yield of the bond? is it higher or lower than the bond’s ytm? why?. If you sold the bond a the end of 1 year what return would you ha..
Independent standard brownian motions : Let Wt and Bt be independent standard Brownian Motions.Find the characteristic function
Specify the consumer maximization problem in this economy : Characterize the competitive equilibrium, and show that it coincides with the solution to the optimal growth problem.
What many consider one of worst deals in sports history : A story reads: "Bobby Bonilla is 52 years old and hasn't played major league baseball since 2001. But the New York Mets will pay Bonilla $1.2 million today in the latest installment of what many consider one of the worst deals in sports history.
Write a program that convert number entered in roman numeral : Write a program that converts a number entered in Roman numerals to decimal form. Your program should consist of a class, say romanType.
Prepare a depreciation schedule for the piece of equipment : A piece of equipment is purchased for $40,000 and has an estimated salvage value of $1,000 at the end of the recovery period. Prepare a depreciation schedule for the piece of equipment using the straight-line method with a recovery period of five yea..
Define a competitive equilibrium : Why does faster technological progress lead to more rapid accumulation of human capital?
Does company mention all components of triple bottom line : Does the company mention all three components of the triple bottom line? Are any operations functions specifically used as part of its sustainability strategy? Do you feel the company is honestly reporting its practices and goals, or do you suspec..
Used to implement business-level strategies : What are the differences between strategic controls and financial controls, and how do they relate to organizational structure? What is the importance of these differences? Discuss the functional structures used to implement business-level strategies..

Reviews

Write a Review

Programming Languages Questions & Answers

  Write a program that will use the four sorting algorithm

Write a program that will use the four sorts (Selection sort, Heap Sort, Quicksort and Merge Sort). Each of the four sorts should be TIMED on three different lists of integers.

  Write a program takes input from a user in the phone

Program takes input from a user in the phone of a phone number, 7 digits plus the hyphen. It then checks whether a user has entered Q to quit, if 0 or 555 are the begging sequence of inputs (if they are the program alerts the user to an error with..

  A method to calculate the value of the entire inventory

Create a method to calculate the value of the entire inventory. Create another method to sort the array items by the name of the product.

  Program read weight of package of breakfast cereal in ounces

Write a program which will read the weight of package of a breakfast cereal in ounces and output weight in metric tons as well as number of boxes

  Write a program that lets the user play the game of rock

Write a program that lets the user play the game of Rock, Paper, Scissors against the computer. When the program begins, the user is asked to seed the random number generator, and a random number in the range of 1 through 3 is generated

  Probability line is executed in nth iteration of for loop

What is the probability that line is executed during the nth iteration of the for loop? What is the exact expected number of executions of line?

  Two-dimensional array to store weekly hours for employees

Assume the weekly hours for all employees are stored in two-dimensional array. Each row records emaployee's seven-day workhours with seven columns.

  Write program which simulates checkout queue object

Write program which simulates checkout line at supermarket. Line is queue object. Customers (i.e., customer objects) arrive in random integer intervals of 1-4 minutes.

  Implement bfs and dfs in c language

Implement BFS and DFS in c language .Explain it also with comments

  Write program in java to input basic salary of persons

Write the program in java to input basic salary of 15 persons. Each one of them gets 25% of basic as hra (house rent allowance), 15 % of basic as conveyance and 10 % of basic as entertainment allowance.

  Find the negation of each of statements

Use de Morgans law to find the negation of each of the subsequent statements - kwame will take a job in industry or go to graduate school.

  Illustrate the progress of each horse in the race

This assignment gives you the opportunity to simulate horse races for up to 10 horses over a range of distances measured in furlongs.

Free Assignment Quote

Assured A++ Grade

Get guaranteed satisfaction & time on delivery in every assignment order you paid with us! We ensure premium quality solution document along with free turntin report!

All rights reserved! Copyrights ©2019-2020 ExpertsMind IT Educational Pvt Ltd