The document outlines 3 problems for a lab exercise on object-oriented programming. Problem 1 asks to write a program that reads input text and outputs each word on a new line. Problem 2 asks to find 10 prime numbers that remain prime when digits are removed from left to right or right to left. Problem 3 asks to write a program to convert roman numerals to Arabic numerals based on symbol values and combination rules.
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
0 ratings0% found this document useful (0 votes)
117 views1 page
OOP - Lab Exercise 2: Problem 1
The document outlines 3 problems for a lab exercise on object-oriented programming. Problem 1 asks to write a program that reads input text and outputs each word on a new line. Problem 2 asks to find 10 prime numbers that remain prime when digits are removed from left to right or right to left. Problem 3 asks to write a program to convert roman numerals to Arabic numerals based on symbol values and combination rules.
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
You are on page 1/ 1
February 7, 2013
OOP Lab Exercise 2
Problem 1:
Write a program that reads one line of input text and breaks it up into words. The words should be output one per line. A word is defined to be a sequence of letters. Any characters in the input that are not letters should be discarded. Sample Input: He said, "That is not a good idea." Sample Output: He said That is not a good idea
Problem 2:
The number 3797 has an interesting property. Being prime itself, it is possible to continuously remove digits from left to right, and remain prime at each stage: 3797, 797, 97, and 7. Similarly we can work from right to left: 3797, 379, 37, and 3. Write a C++ program which finds 10 primes that are both truncatable from left to right and right to left.
Problem 3:
Write a program to convert roman numerals into their Arabic equivalent. Sample Input: XII Sample Output: 12
Following are the roman symbols with their equivalent arabic symbols Roman symbols Arabic Symbols I 1 V 5 X 10 L 50 C 100 D 500 M 1000 Rules: 1. A symbol following one of greater or equal value adds to its value. (E.g., XII = 12) 2. A symbol preceding one of greater value subtracts its value.(E.g., IV = 4; XL = 40)