answersLogoWhite

0

import java.io.* ;

public class Roman

{

public static void main(String[] args)throws IOException

{

InputStreamReader reader = new InputStreamReader(System.in) ;

BufferedReader br = new BufferedReader (reader) ;

System.out.print("Enter any decimal number between 1 and 59 : ") ;

int n = Integer.parseInt(br.readLine()) ;

String c[] = {"I","II","III","IV","V","VI","VII","VIII","IX","X","L"} ;

String s = "" ;

int t ;

if(n <= 10)

System.out.println("The number '"+n+"' in ROMAN notation is '"+(c[n-1])+"'") ;

else if(n > 10 && n <= 59)

{

int y = n/10 ;

int r = n%10 ;

if(y 0)

s = s+c[10] ;

}

else

{

if(r!=0)

s = s+c[r-1] ;

}

System.out.println("The number '"+n+"' in ROMAN notation is '"+s+"'") ;

}

else

System.out.println("!! FATAL ERROR !! [ No. Greater than 59 ] ") ;

}

}

User Avatar

Wiki User

15y ago

Still curious? Ask our experts.

Chat with our AI personalities

JudyJudy
Simplicity is my specialty.
Chat with Judy
BeauBeau
You're doing better than you think!
Chat with Beau
TaigaTaiga
Every great hero faces trials, and you—yes, YOU—are no exception!
Chat with Taiga

Add your answer:

Earn +20 pts
Q: Write a program that converts a decimal number to Roman number. Decimal Number is accepted as command line input at the time of execution.?
Write your answer...
Submit
Still have questions?
magnify glass
imp