import java.io.*; class RomanNumber { static String[]arr1={"","I","II","III","IV","V","VI","VII","VIII","IX"}; static String[]arr2={"","X","XX","XXX","XL","L"}; public static void main(String args[])throws Exception { BufferedReader br =new BufferedReader (new InputStreamReader(System.in)); int d1,d2; System.out.println("Enter the number in Decimal number system (1-50):"); int num=Integer.parseInt(br.readLine()); if(num<=50) { if(num<10) { d1=num%10; System.out.println("Roman number is:"+arr1[d1]); } else { d1=num%10; d2=num/10; System.out.println("Roman number is:-"+arr2[d2]+arr1[d1]); } } else { System.out.println("Number is not between 1 to 50"); } } }
Sabtu, Jun 08, 2013
JAVA : Menukar Nilai Decimal Kepada Angka Roman
Langgan:
Catat Ulasan (Atom)
0 ulasan:
Catat Ulasan
Selamat datang ke 0x2013LΣΣT. Sekiranya anda mempunyai persoalan, pandangan, permintaan, bantuan, cadangan dan sebagainya. Tinggalkan pesanan anda ke dalam kotak komen. Terima kasih !
- http://0x2013.blogspot.com -