TrabalhosGratuitos.com - Trabalhos, Monografias, Artigos, Exames, Resumos de livros, Dissertações
Pesquisar

A Linguagem de Programação III

Por:   •  7/9/2015  •  Trabalho acadêmico  •  2.306 Palavras (10 Páginas)  •  213 Visualizações

Página 1 de 10

[pic 1]

package Vetor;

import javax.swing.JOptionPane;

public class Teste {

        public static void main(String[] args) {

                String u[],d[],c[];

                u= new String[20];

                d= new String[10];

                c= new String[10];

                

                try {

                        

                

                u[0]="zero";

                u[1]="um";

                u[2]="dois";

                u[3]="três";

                u[4]="quatro";

                u[5]="cinco";

                u[6]="seis";

                u[7]="sete";

                u[8]="oito";

                u[9]="nove";

                u[10]="dez";

                u[11]="onze";

                u[12]="doze";

                u[13]="treze";

                u[14]="quatorze";

                u[15]="quinze";

                u[16]="dezesseis";

                u[17]="dezesete";

                u[18]="dezoito";

                u[19]="dezenove";

                

                d[0]="";

                d[1]="";

                d[2]="vinte";

                d[3]="trinta";

                d[4]="quarenta";

                d[5]="cinquenta";

                d[6]="sessenta";

                d[7]="setenta";

                d[8]="oitenta";

                d[9]="noventa";

                

                

                c[0]="";

                c[1]="cento";

                c[2]="duzentos";

                c[3]="trezentos";

                c[4]="quatrocentos";

                c[5]="quinhentos";

                c[6]="seiscentos";

                c[7]="setecentos";

                c[8]="oitocentos";

                c[9]="novecentos";

                

                String txtNum;

                int num,nu,nd,nc;

                

                txtNum = JOptionPane.showInputDialog("Digite o Numero");

                num = Integer.parseInt(txtNum);

                

                if (num<=20){

                        System.out.println(u[num]);

                }else{

                        if (num<100){

                                nd = Integer.parseInt(txtNum.substring(0, 1));

                                nu = Integer.parseInt(txtNum.substring(1, 2));

                                System.out.println( d[nd] + " e " + u[nu] );

                        }

                        else{

                                if (num<101 && num>99){

                                System.out.println("cem");

                        }

                                else{

                                        if (num<1000){

                                                nc = Integer.parseInt(txtNum.substring(0, 1));

...

Baixar como (para membros premium)  txt (3.9 Kb)   pdf (57.4 Kb)   docx (32.6 Kb)  
Continuar por mais 9 páginas »
Disponível apenas no TrabalhosGratuitos.com