Please Write code in visual studio
Roman Numeral Converter
Write a program that asks the user to enter a number within the range of 1 through 10.
Use a switch statement to display the Roman numeral version of that
number.
Input Validation: Decide how the program should handle an input
that is less then 1 or greater than 10.
#include<bits/stdc++.h>
using namespace std;
string roman_conv(int n) {
switch(n) {
case 1: return "I";
case 2: return "II";
case 3: return "III";
case 4: return "IV";
case 5: return "V";
case 6: return "VI";
case 7: return "VII";
case 8: return "VIII";
case 9: return "IX";
case 10: return "X";
default: return "Invalid Input";
}
}
int main() {
int n;
cin>>n;
cout<<roman_conv(n)<<endl;
}
Get Answers For Free
Most questions answered within 1 hours.