Вы находитесь на странице: 1из 10

1.

dados 4 numeros hallar la suma public class Ejerciciosuno { /** * @param args */ public static void main(String[] args) { int n1; int n2; int n3; int n4; int s=0; n1=Integer.parseInt(JOptionPane.showInputDialog("dgite primer numero")); n2=Integer.parseInt(JOptionPane.showInputDialog("digite segundo numero")); n3 =Integer.parseInt(JOptionPane.showInputDialog("digite tercer numero")); n4= Integer.parseInt(JOptionPane.showInputDialog("digite cuarto numero")); s=n1+n2+n3+n4; JOptionPane.showMessageDialog(null,"la suma es "+String.valueOf(s)); } }

2.dados n nmeros contar los nmeros mayores a 10 y sumar los menores a 10


public static void main(String[] args) { int n; int cn=0; int sn=0; n=Integer.parseInt(JOptionPane.showInputDialog("digite cantidad numeros")); for (int i = 0; i <(n-1) ; i++) { int nm = Integer.parseInt(JOptionPane.showInputDialog("digite numeros")); if (nm>10){ cn=cn+1;} else { sn=sn+nm;} } JOptionPane.showMessageDialog(null," cantidad de mayores "+String.valueOf(cn)); JOptionPane.showMessageDialog(null," suma de menores "+String.valueOf(sn)); } }

3.Dado n nmeros contar los mayores 40 y sumar menores a 25


public static void main(String[] args) { int n; int cn=0; int sn=0; n=Integer.parseInt(JOptionPane.showInputDialog("digite cantidad numeros")); for (int i = 0; i <(n-1) ; i++) { int nm = Integer.parseInt(JOptionPane.showInputDialog("digite numeros")); if (nm>40){ cn=cn+1;} if (nm<25){ sn=sn+nm;} } JOptionPane.showMessageDialog(null," cantidad de mayores "+String.valueOf(cn)); JOptionPane.showMessageDialog(null," suma de menores "+String.valueOf(sn)); } } 4.dado n numero hallar el promedio de esos numeros public class ejericiicocuarto { /** * @param args */ public static void main(String[] args) { int n; int sn=0; int pro=0; n=Integer.parseInt(JOptionPane.showInputDialog("digite cantidad numeros")); for (int i = 0; i <(n-1) ; i++) { int nm = Integer.parseInt(JOptionPane.showInputDialog("digite numeros")); sn=sn+nm; } pro=sn/n; JOptionPane.showMessageDialog(null,"el promedio es "+String.valueOf(pro)); } }

5 .dados n hallar el porcentaje de los menores a 15 y porcentaje de los mayores


public static void main(String[] args) { int n; int cn=0; int porcme=0; int cnm=0; int porcm=0; n=Integer.parseInt(JOptionPane.showInputDialog("digite cantidad numeros")); for (int i = 0; i <(n-1) ; i++) { int nm = Integer.parseInt(JOptionPane.showInputDialog("digite numeros")); if (nm>15){ cnm=cnm+1;} else { cn=cn+1;} } porcm=(cnm*100/n); porcme=(cn*100/n); JOptionPane.showMessageDialog(null," porcentaje mayores "+String.valueOf(porcm)); JOptionPane.showMessageDialog(null," porcentaje menores "+String.valueOf(porcme)); } } 6. Dado n numeros hallar el promedio de los nmeros mayores a 20 y el porcentaje de los menores a 10. public static void main(String[] args) { int n; int sn=0; int proma=0; int snm=0; int prome=0; n=Integer.parseInt(JOptionPane.showInputDialog("digite cantidad numeros")); for (int i = 0; i <(n-1) ; i++) { int nm = Integer.parseInt(JOptionPane.showInputDialog("digite numeros")); if (nm>20){ snm=snm+nm;} if (nm<10){ sn=sn+nm;} } prome=(sn/n); proma=(snm/n); JOptionPane.showMessageDialog(null," porcentaje mayores "+String.valueOf(proma)); JOptionPane.showMessageDialog(null," porcentaje menores "+String.valueOf(prome)); }}

7 dado n personas hallar la cantidad de hombres pormedio de edad de los hombres porcentaje mujeres casadas con hijos.

public static void main(String[] args) { int n; int ch=0; int cmc=0; int se=0; int cas=0; int ped=0; int cm=0; int pormu=0; n=Integer.parseInt(JOptionPane.showInputDialog("digite cantidad personas")); for (int i = 0; i <(n-1) ; i++) { String g=JOptionPane.showInputDialog("digite genero"); if (g.equals("f")) { cm=cm+1; String ec=JOptionPane.showInputDialog("digite estado civil"); if (ec.equals("casada")){ cas=cas+1; String h = JOptionPane.showInputDialog("hijos?"); if (h.equals("si")){ cmc=cmc+1; } } } else { ch=ch+1; int ed=Integer.parseInt(JOptionPane.showInputDialog("digite edad")); se=se+ed; } } ped=se/ch; pormu=(cmc*100)/cm; JOptionPane.showMessageDialog(null,"cantidad hombres"+String.valueOf(ch)); JOptionPane.showMessageDialog(null,"promedio edad hombres"+String.valueOf(ped)); JOptionPane.showMessageDialog(null,"porcentaje mujeres casadas hijos"+String.valueOf(pormu)); } }

8. Dado n alumnos hallar Definitiva de matemticas que se saca de un promedio de tres notas ,definitiva de espaol que vale 70% una nota y el 30% ,definitiva ingles que es el promedio de 2 notas.
public static void main(String[] args) { int n; float defm=0; float des=0; float ding=0; n=Integer.parseInt(JOptionPane.showInputDialog("digite cantidad personas")); for (int i = 0; i <(n-1) ; i++) { float ma1=Integer.parseInt(JOptionPane.showInputDialog("digite nota mate 1")); float ma2=Integer.parseInt(JOptionPane.showInputDialog("digite nota mate 2")); float ma3=Integer.parseInt(JOptionPane.showInputDialog("digite nota mate 3")); float es1= Integer.parseInt(JOptionPane.showInputDialog("digite nota espaol 1")); float es2= Integer.parseInt(JOptionPane.showInputDialog("digite nota espaol 2")); float ing1=Integer.parseInt(JOptionPane.showInputDialog("digote nota ingles 1")); float ing2=Integer.parseInt(JOptionPane.showInputDialog("digite nota ingles 2")); defm=ma1+ma2+ma3/3; JOptionPane.showMessageDialog(null,"promedio matematicas"+String.valueOf(defm)); des=es1*70/100+es2*30/100; JOptionPane.showMessageDialog(null,"promedio espaol"+String.valueOf(des)); ding=ing1+ing2/2; JOptionPane.showMessageDialog(null,"promedio ingles"+String.valueOf(ding)); } } }

9. Dado n estudiantes de cada alumno sacar la definitiva de ocho materias hallar el promedio por alumno y el del grupo general.
public static void main(String[] args) { int n; float def=0; n=Integer.parseInt(JOptionPane.showInputDialog("digite cantidad personas")); for (int i = 0; i <(n-1) ; i++) { float ma1=Integer.parseInt(JOptionPane.showInputDialog("digite nota mate 1")); float ma2=Integer.parseInt(JOptionPane.showInputDialog("digite nota mate 2")); float ma3=Integer.parseInt(JOptionPane.showInputDialog("digite nota mate 3")); float ma4= Integer.parseInt(JOptionPane.showInputDialog("digite nota mate 4")); float ma5= Integer.parseInt(JOptionPane.showInputDialog("digite nota mate 5")); float ma6=Integer.parseInt(JOptionPane.showInputDialog("digote nota mate 6")); float ma7=Integer.parseInt(JOptionPane.showInputDialog("digite nota mate 7")); float ma8=Integer.parseInt(JOptionPane.showInputDialog("digite nota mat 8")); def=ma1+ma2+ma3+ma4+ma5+ma6+ma7+ma8/8; JOptionPane.showMessageDialog(null,"promedio es"+String.valueOf(def)); } defg=sdef/n; JOptionPane.showMessageDialog(null,"pormedio grupo es"+String.valueOf(defg)); }}

10. tenemos n personas sabemos su edad genero nombre salario hallar: Cantidad mujeres que tienen de 20 a 30 aos Promedio de edad entre los hombres Porcentaje q ganan ms 2000000 Cantidad cuya edad es mayor a a 35 y salario menor a un milln

public static void main(String[] args) { int n; int cpe=0; int cpm=0; int peh=0; int cp=0; int s=0; int cs=0; int ch=0; int por=0; int sa=0; n=Integer.parseInt(JOptionPane.showInputDialog("digite cantidad de personas")); for (int i = 0; i <(n-1) ; i++) { int e=Integer.parseInt(JOptionPane.showInputDialog("digite edad")); if (e<35){ cpe=cpe+1; } sa=Integer.parseInt(JOptionPane.showInputDialog("digite valor salario")); if (sa<1000000){ cp=cp+1; } else{ if (sa<=2000000){ s=s+sa; cs=cs+1; } } String g=JOptionPane.showInputDialog("digite genero"); if (g.equals("f")){ if (e>20 && e<30) { cpm=cpm+1; } } else { ch=ch+1; s=s+e; } } peh=s/ch; por=(cs*100)/n; JOptionPane.showMessageDialog(null,"cantidad mujeres ed"+String.valueOf(cpm)); JOptionPane.showMessageDialog(null,"promedio edad hombres"+String.valueOf(peh)); JOptionPane.showMessageDialog(null, "porcentaje ganan dos"+String.valueOf(por)); JOptionPane.showMessageDialog(null,"cantidad edad mayor"+String.valueOf(cpe)); } }

11. Dado n personas teniendo su edad nombre genero hallar: Persona edad mayor persona edad menor Cantidad persona edad mayor Personas edad menor Cantidad mujeres edad entre 28 y 40 Cantidad cuyo nombre es diego public static void main(String[] args) { n; me=0; ma=0; nma=0; nme=0; re =0; cm=0; cmo=0; nd=0;

int int int int int int int int int

n=Integer.parseInt(JOptionPane.showInputDialog("digite cantidad de personas")); for (int i = 0; i <(n-1) ; i++) { int e=Integer.parseInt(JOptionPane.showInputDialog("digite edad")); if (e<ma){ ma=e; nma=n; } if (e>me){ me=e; nme=n; } re= e % 4; if (re==0){ cm=cm+1; } String g=JOptionPane.showInputDialog("digite genero");{ if(g.equals("f")){ if (e>28 && e<40){ cmo=cmo+1; }} else { String nom=JOptionPane.showInputDialog("digite nombre"); if (nom.equals("diego")){ nd=nd+1; } } JOptionPane.showMessageDialog(null,"persona edad mayor"+String.valueOf(ma)); JOptionPane.showMessageDialog(null,"cantidad edad 4"+String.valueOf(cm)); JOptionPane.showMessageDialog(null, "personas edad menor"+String.valueOf(nme));

JOptionPane.showMessageDialog(null, "mujeres edaden"+String.valueOf(cmo)); JOptionPane.showMessageDialog(null,"cantidad diego"+String.valueOf(nd));

}}}}

12 dado n personas se desea saber cuntas de ellas cumplen con los siguientes requisitos debe cumplir todas para otorgar la beca -estrato 1 y tenga sisben -edad entre 18-25 40 .45 -deben vivir mas de 3 kilometros de la intitucion -debe presentar pormedio superior a 4,5 en 10 y 11. public static void main(String[] args) { int n ; int e;

n=Integer.parseInt(JOptionPane.showInputDialog("digite cantidad personas")); for (int i = 0; i <(n-1) ; i++) { int e=Integer.parseInt(JOptionPane.showInputDialog("digite edad")); if (e>18 && e<25) || (e>40 && e<45){ }

13.dados n estudiantes se desea liquidar el valor a pagar de matricula dependiendo de lo siguiente a.si estudia finaciera la matricula el valor es $2000000 b. si estudia derecho $2500000 c. indepedniente de la carrera debe tomar dos lectivas natacin $80000 futboll $50000 ajedrez $60000 d. si el estrato es 10 2 descuento del 5% e si tiene sisben 3% f primer semestre no tiene descuento g si ya curso promedio 4 8%

12liquidar matricula sisben y estrato 1 10 %descuento Vive fuera del municipio descuento 15000 Promedio superior a 4 descuento 100000

13 liquidar matricula Hallar personas q pagan ms de 100 000 promedio del grupo total recolectado de matriculas porcentaje de personas promedio es mayor 4,0.

Вам также может понравиться