0% found this document useful (0 votes)
19 views5 pages

Lan Clint Offemaria: Final Project

Uploaded by

chouanny07
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as DOCX, PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
19 views5 pages

Lan Clint Offemaria: Final Project

Uploaded by

chouanny07
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as DOCX, PDF, TXT or read online on Scribd
You are on page 1/ 5

Computer Arts and Technological College, Inc.

Name: Diego A. Maraya Date: 12/05/2023

Course & Year: BSIT 1-C Subject & Time: Computer Programming 2:30-4:00

Instructor: Sir lan Clint Offemaria

FINAL PROJECT

Task 1:Create a program that will accept a number and convert the accepted
number to a roman number. Range of value 1-3999. If the value is not in the range
display "OUT OF RANGE" otherwise if the value is within the range display the
converted value in ROMAN NUMBERS.

#include <iostream>
#include <string>
using namespace std;

string intToRoman(int num) {


string roman = "";

roman += string(num / 1000, 'M');


num %= 1000;

if (num >= 900) {


roman += "CM";
num -= 900;
} else if (num >= 500) {
roman += "D";
num -= 500;
} else if (num >= 400) {
roman += "CD";
num -= 400;
}
roman += string(num / 100, 'C');
num %= 100;

if (num >= 90) {


roman += "XC";
num -= 90;
} else if (num >= 50) {
roman += "L";
num -= 50;
} else if (num >= 40) {
roman += "XL";
num -= 40;
}
roman += string(num / 10, 'X');
num %= 10;

if (num >= 9) {
roman += "IX";
num -= 9;
} else if (num >= 5) {
roman += "V";
num -= 5;
} else if (num >= 4) {
roman += "IV";
num -= 4;
}
roman += string(num, 'I');

return roman;
}
int main() {
int num;
cout << "Enter a number : ";
cin >> num;

cout << endl;

if (num < 1 || num > 3999) {


cout << "OUT OF RANGE" << endl;

} else {
cout << num << " in roman is " << intToRoman(num) << endl;

}
return 0;
}
Task 2: Create a program that will accept a number and convert the accepted
number to a word. The range to be accepted is from 1 to 999999999.

You might also like