Problemas propuestos

10
PROBLEMAS PROPUESTOS 11° /* * To change this template, choose Tools | Templates * and open the template in the editor. */ package propuesto011; import java.io.*; /** * * @author ERIKA */ public class Propuesto011 { /** * @param args the command line arguments */ public static void main(String[] args) throws IOException { int edad; BufferedReader in =new BufferedReader(new InputStreamReader(System.in)); System.out.println("ingresa la edad de cualquier persona"); edad = Integer.parseInt(in.readLine()); if(edad>=18) System.out.println("la persona es mayor de edad"); else System.out.println("la persona es menor de edad"); } }

Transcript of Problemas propuestos

Page 1: Problemas propuestos

PROBLEMAS PROPUESTOS

11°

/* * To change this template, choose Tools | Templates * and open the template in the editor. */package propuesto011;import java.io.*;/** * * @author ERIKA */public class Propuesto011 {

/** * @param args the command line arguments */ public static void main(String[] args) throws IOException { int edad; BufferedReader in =new BufferedReader(new InputStreamReader(System.in)); System.out.println("ingresa la edad de cualquier persona"); edad = Integer.parseInt(in.readLine()); if(edad>=18) System.out.println("la persona es mayor de edad");

else

System.out.println("la persona es menor de edad"); }}

Page 2: Problemas propuestos

12°

/* * To change this template, choose Tools | Templates * and open the template in the editor. */package propuesto012;import java.io.*;/** * * @author ERIKA */public class Propuesto012 {

/** * @param args the command line arguments */ public static void main(String[] args) throws IOException { int n1,n2,m; BufferedReader in=new BufferedReader(new InputStreamReader(System.in)); System.out.println("Número 1: "); n1= Integer.parseInt(in.readLine()); System.out.println("Número 2: "); n2=Integer.parseInt(in.readLine()); if (n1>n2) {

m=n2; } else { m=n1; }

System.out.println(""); System.out.println("Menor: "+m); }}

Page 3: Problemas propuestos

13°

/* * To change this template, choose Tools | Templates * and open the template in the editor. */package propuesto013;import java.io.*;/** * * @author ERIKA */public class Propuesto013 {

/** * @param args the command line arguments */ public static void main(String[] args) throws IOException{ int a,b; BufferedReader in=new BufferedReader(new InputStreamReader(System.in)); System.out.println("Número 1: "); a= Integer.parseInt(in.readLine()); System.out.println("Número 2: "); b=Integer.parseInt(in.readLine()); if(a==b) System.out.println("números son iguales");

else

System.out.println("números son diferentes"); }}

Page 4: Problemas propuestos

14°

/* * To change this template, choose Tools | Templates * and open the template in the editor. */package propuesto014;import java.util.Scanner;/** * * @author ERIKA */public class Propuesto014 {

/** * @param args the command line arguments */ public static void main(String[] args) { int a,b;

Scanner teclado=new Scanner(System.in); System.out.print("ESCRIBIR UN NÚMERO:"); a=teclado.nextInt(); //PROCESO if (a>0){ b=a*2; }else{ if (a<0){ b=a*3; }else{ b=0; } } System.out.println(""); System.out.println("EL RESULTADO ES: "+b); } }

Page 5: Problemas propuestos

15°

/* * To change this template, choose Tools | Templates * and open the template in the editor. */package propuesto015;import java.util.Scanner;/** * * @author ERIKA */public class Propuesto015 {

/** * @param args the command line arguments */ public static void main(String[] args) { int a,b,c,Ma=0,I=0,Me=0; Scanner teclado=new Scanner(System.in); System.out.print("PRIMER NÚMERO:"); a=teclado.nextInt(); System.out.print("SEGUNDO NÚMERO:"); b=teclado.nextInt(); System.out.print("TERCER NÚMERO:"); c=teclado.nextInt(); if (a>b && a>c){ Ma=a; }else{ if (b>a && b>c){ Ma=b; }else{ Ma=c; } } if(a<b &&a<c){ Me=a; }else{ if (b<a&&b<c){ Me=b; }else{ Me=c; } } I=(a+b+c)-(Ma + Me); System.out.println(""); System.out.println("ORDEN DESCENDENTE: "); System.out.println("MAYOR: "+Ma); System.out.println("INTERMEDIO: "+I); System.out.println("MENOR: "+Me); System.out.println("ORDEN ASCENDENTE: "); System.out.println("MENOR: "+Me); System.out.println("INTERMEDIO: "+I);

Page 6: Problemas propuestos

System.out.println("MAYOR: "+Ma); }}

16°

/* * To change this template, choose Tools | Templates * and open the template in the editor. */package propuesto016;import java.util.Scanner;/** * * @author ERIKA */public class Propuesto016 {

/** * @param args the command line arguments */ public static void main(String[] args) { int a,b,c,d,Pr=0; String X; Scanner teclado=new Scanner(System.in); System.out.print("NOTA 1:"); a=teclado.nextInt(); System.out.print("NOTA 2:"); b=teclado.nextInt(); System.out.print("NOTA 3:"); c=teclado.nextInt(); System.out.print("NOTA 4:"); d=teclado.nextInt(); if(a<b &&a<c && a<d){ Pr=(b+c+d)/3; }else{ if (b<a&&b<c && b<d){ Pr=(a+c+d)/3; }else{ if (c<a&&c<b && c<d){ Pr=(a+b+d)/3; }else{ Pr=(a+b+c)/3; } } } if(Pr>=11){ X="APROBADO"; }else{ X="DESAPROBADO"; } System.out.println("");

Page 7: Problemas propuestos

System.out.println("PROMEDIO: "+Pr); System.out.println("CONDICIÓN: "+X); }}

17°/* * To change this template, choose Tools | Templates * and open the template in the editor. */package propuesto017;import java.util.Scanner;/** * * @author ERIKA */public class PROPUESTO017 {

/** * @param args the command line arguments */ public static void main(String[] args) { int sal_ant, monto, sal_actual=0; char tipo_mov; Scanner teclado = new Scanner(System.in); System.out.print("Ingresar el Saldo: "); sal_ant=teclado.nextInt(); System.out.print("Ingresar el Tipo de Movimiento: "); tipo_mov = teclado.next().charAt(0); System.out.print("Ingresar el Monto: "); monto=teclado.nextInt(); if(tipo_mov=='R'){ sal_actual = sal_ant - monto; } else { if(tipo_mov=='D'){ sal_actual = sal_ant + monto; } } System.out.println(""); System.out.print("El saldo actual es: "+sal_actual); System.out.println(); } }

Page 8: Problemas propuestos

18°

/* * To change this template, choose Tools | Templates * and open the template in the editor. */package propuesto018;import java.util.Scanner;/** * * @author ERIKA */public class PROPUESTO018 {

/** * @param args the command line arguments */ public static void main(String[] args) { int a,b; String X = "";

Scanner teclado=new Scanner(System.in); System.out.print("1er Número(A):"); a=teclado.nextInt(); System.out.print("2do Número(B):"); b=teclado.nextInt(); if(a>b){ X = "A es mayor que B"; }else{ if(b>a){ X = "B es Mayor que A"; } } if(a==b){ X = "A es igual a B"; } System.out.println(""); System.out.println("EL RESULTADO ES: " +X); }}