Bueno, primeramente quiero agradecer a mi hermano ps1c0s1s, ya que sin él, no sería nada, me brindó toda su atención y ayuda. Un Aplauso para él

¿Qué hace el código?: Pide una cifra, y muestra su cociente; o sea, nos muestra cuantas veces cabe la cifra en el número colocado.

Código: Seleccionar todo

import javax.swing.JOptionPane;

public class Inicio {
    public static void main(String[] args) {
        int Cifra, Cincomil, Dosmil, Mil, Quinientos, Doscientos, Cien, Cincuenta, Veinte, Diez, Cinco, Dos, Uno;

        Cifra = Integer.parseInt(JOptionPane
                .showInputDialog("DIGITE UN NUMERO ENTERO"));
        if (Cifra < 1000) {
            JOptionPane.showMessageDialog(null,"EL NUMERO DEBE TENER 4 DIGITOS");
        }
        if (Cifra > 9999) {
            JOptionPane.showMessageDialog(null,"EL NUMERO DEBE TENER 4 DIGITOS");
            
    } else {
            if (Cifra > 5000) {
                Cincomil = Cifra / 5000;
                JOptionPane.showMessageDialog(null,"BILLETES DE CINCOMIL: "+ Cincomil);
                Cifra = Cifra % 5000;
                
            } else {
                
                JOptionPane.showMessageDialog(null,"BILLETES DE CINCOMIL: " + 0);
            }
            if (Cifra > 2000) {
                Dosmil = Cifra / 2000;
                JOptionPane.showMessageDialog(null,"BILLETES DE DOSMIL: "+ Dosmil);
                Cifra = Cifra % 2000;
    } else {
                JOptionPane.showMessageDialog(null,"BILLETES DE DOSMIL: " + 0);
            }
        if (Cifra > 1000) {
                Mil = Cifra / 1000;
                JOptionPane.showMessageDialog(null, "BILLETES DE MIL: " + Mil);
                Cifra = Cifra % 1000;
        } else {
                JOptionPane.showMessageDialog(null,"BILLETES DE MIL: " + 0);
            }
            if (Cifra > 500) {
                Quinientos = Cifra / 500;
                JOptionPane.showMessageDialog(null, "MONEDAS DE QUINIENTOS: "+ Quinientos);
                Cifra = Cifra % 500;
            } else {
                JOptionPane.showMessageDialog(null,"MONEDAS DE QUINIENTOS: " + 0);
            }
            if (Cifra > 200) {
                Doscientos = Cifra / 200;
                JOptionPane.showMessageDialog(null, "MONEDAS DE DOSCIENTOS: "+ Doscientos);
                Cifra = Cifra % 200;
            } else {
                JOptionPane.showMessageDialog(null,"MONEDAS DE DOSCIENTOS: " + 0);
            }
            if (Cifra > 100) {
                Cien = Cifra / 100;
                JOptionPane.showMessageDialog(null, "MONEDAS DE CIEN: " + Cien);
                Cifra = Cifra % 100;
            } else {
                JOptionPane.showMessageDialog(null,"MONEDAS DE CIEN: " + 0);
            }
            if (Cifra > 50) {
                Cincuenta = Cifra / 50;
                JOptionPane.showMessageDialog(null, "MONEDAS DE CINCUENTA: "+ Cincuenta);
                Cifra = Cifra % 50;
            } else {
                JOptionPane.showMessageDialog(null,"MONEDAS DE CINCUENTA: " + 0);
            }
            if (Cifra > 20) {
                Veinte = Cifra / 20;
                JOptionPane.showMessageDialog(null, "MONEDAS DE VEINTE: "+ Veinte);
                Cifra = Cifra % 20;
            } else {
                JOptionPane.showMessageDialog(null,"MONEDAS DE VEINTE: " + 0);
            }
            if (Cifra > 10) {
                Diez = Cifra / 10;
                JOptionPane.showMessageDialog(null, "MONEDAS DE DIEZ: " + Diez);
                Cifra = Cifra % 10;
            } else {
                JOptionPane.showMessageDialog(null,"MONEDAS DE DIEZ: " + 0);
            }
            if (Cifra > 5) {
                Cinco = Cifra / 5;
                JOptionPane.showMessageDialog(null, "MONEDAS DE CINCO: "+ Cinco);
                Cifra = Cifra % 5;
            } else {
                JOptionPane.showMessageDialog(null,"MONEDAS DE CINCO: " + 0);
            }
            if (Cifra > 2) {
                Dos = Cifra / 2;
                JOptionPane.showMessageDialog(null,"MONEDAS DE DOS: " + Dos);
                Cifra = Cifra % 2;
            } else {
                JOptionPane.showMessageDialog(null,"MONEDAS DE DOS: " + 0);
            }
            if (Cifra > 1) {
                Uno = Cifra / 1;
                JOptionPane.showMessageDialog(null,"MONEDAS DE UNO: " + Uno);
            } else {
                JOptionPane.showMessageDialog(null,"MONEDAS DE UNO: " + 0);
            }
        }

    }
}
PD: Las variables integer, son puestas por mí, son valores de monedas Colombianas, ustedes lo modifican a su gusto, sea lo que sea, valores normales, pijas, ortos, chotas, etc...

ByeOff;
Responder

Volver a “Otros lenguajes”