Write a program that does the following:
Asks the user to enter an integer
Prints the integer in Roman numerals
1.) Asks the user if they'd like to convert another integer
2.) If the user enters 'n' or 'N': end the program (return 0;)
3.) If the user enters anything else: go back to step 1
This is what I have so far but I keep getting errors, I don't get what I'm doing wrong.
#include <iostream>
#include <string>
using namespace std;
int main(){
string answer;
int integer;
int num;
int y;
cout << "Please enter an integer: ";
cin >> integer;
cout << "Would you like to convert another integer(Y / N)?";
while (answer == 'Y' && answer != 'N');
if (num >= 1){
answer += 'I';
num -= 1;
}
else if (num >= 5){
answer += 'V';
num -= 5;
}
else if (num >= 10){
answer += 'X';
num += 10;
}
else if (num >= 50){
answer += 'L';
num -= 50;
}
else if (num >= 100){
answer += 'C';
num -= 100;
}
else if (num >= 500){
answer += 'D';
num -= 500;
}
else if (num >= 1000){
answer += 'M';
num -= 1000;
}
}
system("pause");
return 0;
This is an example of what the output should be:
Please enter an integer: 123
--> CXXIII
Would you like to convert another integer (Y/N)? y
Please enter an integer: 401
--> CDI
Would you like to convert another integer (Y/N)? y
Please enter an integer: 1299
--> MCCXCIX
Would you like to convert another integer (Y/N)? n