Source Code Java NetBeans : Konversi Bilangan Bulat ke Bilangan Romawi
package konversibilanganbulatkebilanganromawikumpulanartikel21blogspotcom;
import java.util.*;
public class KonversiBilanganBulatKeBilanganRomawiKumpulanArtikel21Blogspotcom {
public static void main(String[] args) {
System.out.println("Program Konversi Bilangan Bulat Ke Bilangan Romawi : Tugas Soal Latihan No.2");
System.out.println("=========================================================");
System.out.println(" Oleh : KumpulanArtikel-21.blogspot.com ");
System.out.println("=========================================================");
System.out.println(" ***Konversi Bilangan Bulat Ke Bilangan Romawi*** ");
System.out.println("=========================================================");
{
int bil;
String tampil="";
String [] biasa = {"","I","II", "III", "IV", "V",
"VI", "VII", "VIII", "IX"};
String [] sepuluh = {"", "X", "XX","XXX","XL"};
String [] limapuluh = {"", "L", "LX", "LXX", "LXXX","XC"};
String [] seratus = {"", "C", "CC", "CCC", "CD"};
String [] limaratus = {"", "D", "DC", "DCC", "DCCC", "CM"};
String [] seribu = {"", "M", "MM", "MMM", "Mv", "v"};
System.out.print("Masukkan bilangan desimal : ");
Scanner obj = new Scanner(System.in);
bil = obj.nextInt();
if (bil>5000)
{
System.out.println("Program Ini Memiliki Keterbatasan "+
"Input yang Anda Masukan HARUS DIBAWAH 5000");
}
else
{
int lmrts = bil % 1000;
int srts = lmrts % 500;
int lmpl = srts % 100;
int spl = lmpl % 50;
int ak = spl % 10;
int a = bil/1000;
tampil += ""+seribu[a];
if ( (lmrts >=900) && (lmrts <= 999))
{
tampil += "CM";
if( (lmpl >= 90) && (lmpl <= 99) )
{
tampil += "XC";
int f= ak/1;
tampil += ""+biasa[f];
}
else
{
int d = lmpl/50;
tampil += ""+limapuluh[d];
int e = spl/10;
tampil += ""+sepuluh[e];
int f= ak/1;
tampil += ""+biasa[f];
} }
else
{
int b = lmrts/500;
tampil += ""+limaratus[b];
if ( (srts >= 400)&& (srts <= 499) )
{
tampil += "CD";
//90
if( (lmpl >= 90) && (lmpl <= 99) )
{
tampil += "XC";
int f= ak/1;
tampil += ""+biasa[f];
}
else
{
int d = lmpl/50;
tampil += ""+limapuluh[d];
int e = spl/10;
tampil += ""+sepuluh[e];
int f= ak/1;
tampil += ""+biasa[f];
} }
else
{
int c = srts/100;
tampil += ""+seratus[c];
if((lmpl >= 90)&&(lmpl <= 99))
{
tampil += "XC";
int f= ak/1;
tampil += ""+biasa[f];
}
else
{
int d = lmpl/50;
tampil += ""+limapuluh[d];
int e = spl/10;
tampil += ""+sepuluh[e];
int f= ak/1;
tampil += ""+biasa[f];
} } }
System.out.println("Maka angka Romawinya "+tampil);
}} }}