You are on page 1of 8

PROGRAMA CON PRUEBA VARIABLE

package promediodosnumeros; import javax.swing.JOptionPane; /** * * @author Luis Cuadros */ public class Main { /** * @param args the command line arguments */ public static void main(String[] args) { // TODO code application logic here int n1, n2; double prom; // // n1=18; n2 = 13;

n1=Integer.parseInt(JOptionPane.showInputDialog("Ingrese el primer numero")); n2=Integer.parseInt(JOptionPane.showInputDialog("Ingrese el segundo numero")); prom=(n1+n2)/2; // System.out.println("El promedio final es="+prom); JOptionPane.showMessageDialog(null,"El promedio fonal es "+prom);

package salarios; import javax.swing.JOptionPane; class Salarios { public static void main(String[] args) { // TODO code application logic here double ht, ph, hn, hs; double pago; ht=Integer.parseInt(JOptionPane.showInputDialog("Ingrese horas trabajadas")); ph=Integer.parseInt(JOptionPane.showInputDialog("Ingrese precio x hora")); hn=ht; hs=0; if (ht>35) {hn=35; hs=ht-hn;} pago=hn*ph + hs*1.75*ph; JOptionPane.showMessageDialog(null,"El salario semana es "+pago); }

****************************************************************************** ***

} ********************************** CAMBIO DE MONEDAS *********************************** import javax.swing.JOptionPane; public static void main(String[] args) { // TODO code application logic here double tcd, tce, monto, nuevomonto; int tmo,tmd; monto=Integer.parseInt(JOptionPane.showInputDialog("Ingrese monto a cambiar")); tcd=Integer.parseInt(JOptionPane.showInputDialog("Ingrese tc de dolar")); tce=Integer.parseInt(JOptionPane.showInputDialog("Ingrese tc de euros"));

tmo=Integer.parseInt(JOptionPane.showInputDialog("Ingrese 1=dolar, 2=euros")); tmd=Integer.parseInt(JOptionPane.showInputDialog("Ingrese 1=dolar, 2=euros"));

nuevomonto=0; if (tcd>tce) JOptionPane.showMessageDialog(null,"error en tipo de cambio ");

if (tmo==tmd) JOptionPane.showMessageDialog(null,"error en tipo de moneda "); if (tmo==1) nuevomonto=monto*tcd/tce; if (tmo==2) nuevomonto=monto*tce/tcd; JOptionPane.showMessageDialog(null,"El nuevo monto es "+nuevomonto);

ARREGLOS
package Acumulador; import javax.swing.JOptionPane;

class Acumulador {

public static void main(String[] args) { // TODO code application logic here int limite; int num; int [] a = new int [20];

double sumador;

limite=Integer.parseInt(JOptionPane.showInputDialog(" Ingrese limite numeros")); // inicio del lazo de carga del arreglo for ( int x=1; x <= limite; x++) { num=Integer.parseInt(JOptionPane.showInputDialog("I ngrese el numero")); if (num>=1 & num<=5) { break; } else; { a[x]= num; System.out.println(a[x]); } } // fin del lazo del for // lazo que permite acumular los valores leidos y cargados en el arreglo sumador=0; for ( int x=1; x <= limite; x++) {

sumador=sumador+a[x]; }

JOptionPane.showMessageDialog(null,"El Acumulado es "+sumador); }

You might also like