import java.applet.Applet; import java.awt.*; import java.awt.event.*; import java.util.StringTokenizer; public class roomanr extends Applet implements ActionListener{ TextField tf1=new TextField(10); TextField tf2=new TextField(20); Button nupp= new Button("Rooma"); public roomanr(){ add(tf1); add(tf2); add(nupp); nupp.addActionListener(this); } public void actionPerformed(ActionEvent e){ String r[]={"I", "II", "III", "IV", "V", "VI", "VII", "VIII", "IX", "X", "L", "C", "D", "M"}; String s=tf1.getText(); int i=Integer.parseInt(s); for(;i>1000;i=i-1000){ tf2.setText(tf2.getText()+""+(r[13])); } if(i==1000){ tf2.setText(tf2.getText()+""+(r[13])); i=i-1000; } if(i==999){ tf2.setText(tf2.getText()+""+(r[0])+""+(r[13])); i=i-999; } for(;i>500;i=i-500){ tf2.setText(tf2.getText()+""+(r[12])); } if(i==500){ tf2.setText(tf2.getText()+""+(r[12])); i=i-500; } if(i==499){ tf2.setText(tf2.getText()+""+(r[0])+""+(r[12])); i=i-499; } if(i>=400){tf2.setText(tf2.getText()+""+(r[11])+""+(r[12])); i=i-400;} for(;i>100;i=i-100){ tf2.setText(tf2.getText()+""+(r[11])); } if(i==100){ tf2.setText(tf2.getText()+""+(r[11])); i=i-100; } if(i==99){ tf2.setText(tf2.getText()+""+(r[0])+""+(r[11])); i=i-99; } if(i>=90){tf2.setText(tf2.getText()+""+(r[9])+""+(r[11])); i=i-90;} for(;i>50;i=i-50){ tf2.setText(tf2.getText()+""+(r[10])); } if(i==50){ tf2.setText(tf2.getText()+""+(r[10])); i=i-50; } if(i==49){ tf2.setText(tf2.getText()+""+(r[0])+""+(r[10])); i=i-49; } if(i>=40){tf2.setText(tf2.getText()+""+(r[9])+""+(r[10])); i=i-40;} for(;i>10;i=i-10){ tf2.setText(tf2.getText()+""+(r[9])); } if(i==10){ tf2.setText(tf2.getText()+""+(r[9])); } if(i==9){ tf2.setText(tf2.getText()+""+(r[8])); } if(i==8){ tf2.setText(tf2.getText()+""+(r[7])); } if(i==7){ tf2.setText(tf2.getText()+""+(r[6])); } if(i==6){ tf2.setText(tf2.getText()+""+(r[5])); } if(i==5){ tf2.setText(tf2.getText()+""+(r[4])); } if(i==4){ tf2.setText(tf2.getText()+""+(r[3])); } if(i==3){ tf2.setText(tf2.getText()+""+(r[2])); } if(i==2){ tf2.setText(tf2.getText()+""+(r[1])); } if(i==1){ tf2.setText(tf2.getText()+""+(r[0])); } } public static void main(String argumendid[]){ Frame f=new Frame(); f.setSize(400, 400); f.add(new roomanr()); f.setBackground(new Color(0xdfffff)); f.setVisible(true); } }