import java.awt.*;
import java.applet.*;


public class Applet1 extends Applet
{
	
	Label etiqueta= new Label("Calculadora");
	String elem1[] ={"0","1","2","3","4","5","6","7","8","9"};
	String elem2[ ]={"+","-","=","BORRAR"};
	String elem3[]={"Decimal","Octal","hexadecimal"};
	Choice num=new Choice();
	Choice oper=new Choice();
	Choice sist= new Choice();
	public int i,acum=0,temp=0,signo=0,igual=0;		
				  
	public void init()
	{
		setBackground(Color.red);
		setForeground(Color.blue);
		for(i=0;i<elem1.length;i++)
			num.addItem(elem1[i]);
		for(i=0;i<elem2.length;i++)
			oper.addItem(elem2[i]);
		for(i=0;i<elem3.length;i++)
			sist.addItem(elem3[i]);
		add(etiqueta);
		add(num);
		add(oper);
		add(sist);	
	}
	public boolean action(Event e, Object o)
	{
		if(e.target==num)
		{
			if(temp<99)
			{
				
temp=temp*10+num.getSelectedIndex();
etiqueta.setText(" "+temp);
}
 return true;
}
 if(e.target==oper)
{
 switch(oper.getSelectedIndex())
{
 case 0: if(igual==0)
						
acum=acum+temp;
else igual=0;
temp=0;signo=1;
break;
			case 1: if(igual==0)
					{
						
if(igual==0)acum=temp;
						else 
acum=acum-temp;
					}
					else igual=0;
					temp=0; signo=2;
					break;
			case 2: if(signo==1)
						
acum=acum+temp;
					if(signo==2)
						
acum=acum-temp;
					etiqueta.setText("  "+acum);
					igual=1;temp=0;
					break;
			case 3: acum=temp=signo=igual=0;
					
etiqueta.setText("0");
					break;
			}
			return true;
		
 
 }

 return false;
	}
	{

			}
}
				
					
				
	

