Professional Documents
Culture Documents
- Desarrollar una aplicación que permita ingresar un número que lo permita convertir en
letras
/*
* To change this template, choose Tools | Templates
* and open the template in the editor.
*/
package conversion;
/**
*
* @author IESTP-JDCH
*/
public class numero extends javax.swing.JApplet {
/**
* Initializes the applet numero
*/
@Override
public void init() {
/*
* Set the Nimbus look and feel
*/
//<editor-fold defaultstate="collapsed" desc=" Look and feel setting code (optional) ">
/*
* If Nimbus (introduced in Java SE 6) is not available, stay with the
* default look and feel. For details see
* http://download.oracle.com/javase/tutorial/uiswing/lookandfeel/plaf.html
*/
try {
for (javax.swing.UIManager.LookAndFeelInfo info :
javax.swing.UIManager.getInstalledLookAndFeels()) {
if ("Nimbus".equals(info.getName())) {
javax.swing.UIManager.setLookAndFeel(info.getClassName());
break;
}
}
} catch (ClassNotFoundException ex) {
java.util.logging.Logger.getLogger(numero.class.getName()).log(java.util.logging.Level.SEVERE,
null, ex);
} catch (InstantiationException ex) {
java.util.logging.Logger.getLogger(numero.class.getName()).log(java.util.logging.Level.SEVERE,
null, ex);
} catch (IllegalAccessException ex) {
java.util.logging.Logger.getLogger(numero.class.getName()).log(java.util.logging.Level.SEVERE,
null, ex);
} catch (javax.swing.UnsupportedLookAndFeelException ex) {
java.util.logging.Logger.getLogger(numero.class.getName()).log(java.util.logging.Level.SEVERE,
null, ex);
}
//</editor-fold>
/*
* Create and display the applet
*/
try {
java.awt.EventQueue.invokeAndWait(new Runnable() {
/**
* This method is called from within the init() method to initialize the
* form. WARNING: Do NOT modify this code. The content of this method is
* always regenerated by the Form Editor.
*/
@SuppressWarnings("unchecked")
// <editor-fold defaultstate="collapsed" desc="Generated Code">
private void initComponents() {
jLabel1.setText("Ingrese un numero");
jButton1.setText("Convertir");
jButton1.addActionListener(new java.awt.event.ActionListener() {
public void actionPerformed(java.awt.event.ActionEvent evt) {
jButton1ActionPerformed(evt);
}
});
for(i=1;i<=candig;i++)
{
System.out.println(N[i]);
}
switch(candig)
{
case 1:
tipo="Unidades";
N[1]=N[1]*1;
break;
case 2:
tipo="Decenas";
N[2]=N[2]*10;
break;
case 3:
tipo="Centenas";
N[2]=N[2]*10;
N[3]=N[3]*100;
break;
case 4:
tipo="Millares";
N[2]=N[2]*10;
N[3]=N[3]*100;
N[4]=N[4]*100;
break;
}
while(candig>0)
{
numero=N[candig];
switch(numero)
{
case 0:
rpta="Cero";
break;
case 1:
rpta="Uno";
break;
case 2:
rpta="Dos";
break;
case 3:
rpta="Tres";
break;
case 4:
rpta="Cuatro";
break;
case 5:
rpta="Cinco";
break;
case 6:
rpta="Seis";
break;
case 7:
rpta="Siete";
break;
case 8:
rpta="Ocho";
break;
case 9:
rpta="Nueve";
break;
case 10:
rpta="Diez";
break;
case 11:
rpta="Once";
break;
case 12:
rpta="Doce";
break;
case 13:
rpta="Trece";
break;
case 14:
rpta="Catorce";
break;
case 20:
rpta="Veinte";
break;
case 30:
rpta="Treinta";
break;
case 40:
rpta="Cuarenta";
break;
case 50:
rpta="Cincuenta";
break;
case 60:
rpta="Sesenta";
break;
case 70:
rpta="Setenta";
break;
case 80:
rpta="Ochenta";
break;
case 90:
rpta="Noventa";
break;
case 100:
rpta="Cien";
break;
case 200:
rpta="Doscientos";
break;
case 300:
rpta="Trescientos";
break;
case 400:
rpta="Cuatrocientos";
break;
case 500:
rpta="Quinientos";
break;
case 600:
rpta="Seiscientos";
break;
case 700:
rpta="Seiscientos";
break;
case 800:
rpta="Ochocientos";
break;
case 900:
rpta="Novecientos";
break;
case 1000:
rpta="Mil";
break;
}
temp=temp+rpta;
candig=candig-1;
jTextField2.setText(""+temp);
}