class Main {
public static void main(String[]
args) {
int num;
System.out.println("please
the number below 5000");
Scanner obj = new
Scanner(System.in);
num = obj.nextInt();
String str = String.valueOf(num);
char []arr = str.toCharArray();
int len = str.length();
int count[] = new int[10];
for(int i=0;i<len;i++){
count[i] = (int)arr[i]-48; }
String ones[] = new
String[]{"","I","II","III","IV","V","VI","VII","VIII",
"IX","X"};
String tens[] = new
String[]{"","X","XX","XXX","XL","L","LX","LXX","LXXX",
"XC","C"};
String hundred[] = new
String[]{"","C","CC","CCC","CD","D","DC","DCC",
"DCCC","CM","M"};
String thousand[] = new
String[]{"","M","MM","MMM","MMMM","~V"};
if(len==4 &&
num<=5000){
String romancounting =
thousand[count[0]]+ hundred[count[1]] + tens[count[2]] + ones[count[3]];
System.out.println(romancounting);
}
else if(len==3) {
String romancounting =
hundred[count[0]]+
tens[count[1]]+ones[count[2]];
System.out.println(romancounting); }
else if(len==2){
String romancounting =
tens[count[0]]+
ones[count[1]];
System.out.println(romancounting); }
else {
System.out.println("Sorrt But
number is invalid!
OutOfRange👌");
} } }
|
Saturday, October 12, 2019
Java program to Convert Integer Number to Roman Number.{By Hottest Way).💣👌 Please Check out .
Arrays in Solidity Programming Language.
Arrays Solidity supports both generic and byte arrays. It supports both fixed size and dynamic arrays. It also supports multidimensional ...
-
Introduction to Java Security The Java security architecture includes a large set of application programming interfaces (APIs), tools, ...
-
Virtual reality (VR) and augmented reality (AR) is all set to transform the way users used to access technology. The headsets can take y...
-
''' Round Robin Scheduling Algorithm The task is to find the Average Waiting Time and Average Turnaround Time of the given ...