ESTRUCTURAS LINEALES: PROGRAMA PARA ESCOGER CUANTAS EDADES DESEAMOS INGRESAR Y BUSCAR LA DESEADA

public class problema1
{public static void main(String[] args)
{System.out.print("¿Cuántas edades desea ingresar?");
int n=Leer.datoInt();
int[] edades=new int[n];
int i;
for(i=0;i
{
System.out.println("ingrese edad No "+(i+1)+":");
edades[i]=Leer.datoInt();
}System.out.println("\nbuscar edad\n");
System.out.print("ingrese edad a buscar:");
int E=Leer.datoInt();
boolean encontrado=false;for(i=0;i
if (edades[i]==E){System.out.println("edad encontrada en el indice:"+i);
encontrado=true;}
}if (encontrado==false)System.out.println("no se encuentra la edad buscada en el array");
System.out.println("\nEdades almacenadas\n");
for(i=0;i
System.out.println("edades["+i+"]:"+edades[i]);
}
}
}




2. PROGRAMA " CLASS DINERO"





import java.io.*;
public class Dineroc {
public static void main(String[] args) throws IOException{
int b200,b100,b50,b20,b10,m5,m2,m1,n,r;
String cad="";
InputStreamReader dsf;
BufferedReader buffer;
dsf=new InputStreamReader(System.in);
buffer=new BufferedReader(dsf);
System.out.print("INGRESE CANTIDAD DE DINERO:");
cad=buffer.readLine();
n=Integer.parseInt(cad);
b200=n/200;
r=n%200;
b100=r/100;
r=r%100;
b50=r/50;
r=r%50;
b20=r/20;
r=r%20;
b10=r/10;
r=r%10;
m5=r/5;
r=r%5;
m2=r/2;
r=r%2;
m1=r/1;
r=r%1;
System.out.println("Billete de 200 :"+b200);
System.out.println("Billete de 100:"+b100);
System.out.println("Billete de 50:"+b50);
System.out.println("Billete de 20 :"+b20);
System.out.println("Billete de 10:"+b10);
System.out.println("moneda de 5:"+m5);
System.out.println("moneda de 2:"+m2);
System.out.println("moneda de 1:"+m1);
}
}

No hay comentarios:

Publicar un comentario