Documentos de Académico
Documentos de Profesional
Documentos de Cultura
package com.compunauta.aprendiendojava;
import java.io.*;
public class NOMBRE {
public static void main(String[] args) {
BufferedReader br=new BufferedReader(new InputStreamReader(System.in));
System.out.println("Hola, ingresa tu nombre");
String nombre;
nombre = br.readLine();}
System.out.println("Hola,"+nombre+"ten un buen dia");
}
package com.compunauta.aprendiendojava;
import java.io.*;
public class NOMBRE {
public static void main(String[] args) {
BufferedReader br=new BufferedReader(new InputStreamReader(System.in));
System.out.println("Hola, ingresa tu nombre");
String nombre;
Int num=0;
nombre = br.readLine();}
System.out.println("Hola,"+nombre+"ten un buen dia");
System.out.println("Hola,"+nombre+"ingresa tu edad");
num=Integer.parselnt(br.readLine());
}
import java.io.*;
public class EMPLEADOS {
public static void main(String[] args) throws IOException{
BufferedReader br=new BufferedReader(new
InputStreamReader(System.in));
System.out.println("Hola, ingresa tu nombre");
String nombre;
nombre=br.readLine();
System.out.println(" Hola, " +nombre+ " ten un buen dia ");
System.exit(0);
}
}
import java.io.*;
public class Provincias {
public static void main(String[] args) throws IOException {
BufferedReader br=new BufferedReader(new InputStreamReader(System.in));
int numero;
String provincia;
System.out.println("Hola, ingresa el nombre de la provincia");
provincia=(br.readLine());}
System.out.println(provincia+ "Ingrese el numero de empleados con titulo");
numero=Integer.parselnt(br.readLine());
System.out.println(provincia+ "Ingrese el numero de empleados sin titulo");
numero=Integer.parselnt(br.readLine());
System.out.println(provincia+ "empleados con titulo" +numero+" empleados
sin titulo"+numero+ );
}
SERIE
public static void main(String[] args){
Scanner sc = new Scanner(System.in);
int numero,fibo1,fibo2,i;
do{
Numeros primos
import java.io.*;
public class LOS20PRIMEROSPRIMOS {
public static void main(String[] args)throws NumberFormatException,
IOException {
BufferedReader br=new BufferedReader(new
InputStreamReader(System.in));
System.out.println ("ingrese la cantidad de numeros primos que
desea");
int n;
n=Integer.parseInt(br.readLine());
int i,total;
i=1;
total= i/n;
for (i=1;i<n;++i);
System.out.println ( "los n numeros primeros son " +total);
while (condicin)
}
while(condicin) {
}
Mientras se cumpla la condicin entre parntesis, se ejecuta el cdigo en el
interior de {} de manera infinita hasta.
import java.io.*;
public class EmpleadoSueldo {
public static void main(String[] args) throws NumberFormatException,
IOException{
BufferedReader Empleado=new BufferedReader(new
InputStreamReader(System.in));
int c,s,d;
String nombre;
c=0;
s=0;
d=0;
System.out.println("Ingrese el codigo del empleado");
c=Integer.parseInt(Empleado.readLine());
System.out.println (" ");
System.out.println("Ingrese el nombre del empleado");
nombre=Empleado.readLine();
System.out.println (" ");
System.out.println("Ingrese el sueldo del empleado");
s=Integer.parseInt(Empleado.readLine());
System.out.println (" ");
}
}
import java.io.*;
public class Empleado {
public static void main(String[] args) throws NumberFormatException,
IOException {
BufferedReader Empleado=new BufferedReader(new
InputStreamReader(System.in));
String nom;
double j,s,a;
int i=1;
while(i==1) {
System.out.println("Ingrese el codigo del empleado");
j=Double.parseDouble(Empleado.readLine());
System.out.println("Ingrese el nombre del empleado");
nom=Empleado.readLine();
System.out.println("Ingrese el sueldo del empleado");
s=Double.parseDouble(Empleado.readLine());
if(s>500)
a=s+s*(0.10);
else
a=s+s*(0.05);
System.out.println("El nuevo sueldo del empleado es: "+a);
System.out.println("Desea ingresar otro empleado: si=1 /
no=0");
i=Integer.parseInt(Empleado.readLine());
if(i==0)
i=0;
}
}
}
import java.io.*;
public class Raiz {
public static void main(String[] args) throws NumberFormatException,
IOException {
BufferedReader Raiz=new BufferedReader(new
InputStreamReader(System.in));
double a=0;
int i,j,k,b,c,d,e,l=1;
while (l==1){
System.out.println("Ingrese el valor entero de x ");
i=Integer.parseInt(Raiz.readLine());
System.out.println("Ingrese el valor entero de y ");
j=Integer.parseInt(Raiz.readLine());
System.out.println("Ingrese el valor entero de z ");
k=Integer.parseInt(Raiz.readLine());
b=(int) Math.pow(i,2);
c=(int) Math.pow(j,2);
d=(int) Math.pow(k,2);
e=b+c+d;
l=e;
a=Math.sqrt(e);
System.out.println("La raiz cuadrada de la suma de los 3
numeros al cuadrado es: "+a);
if (l==0);
else
l=1;
}
}
}
import java.io.*;
public class MenuNumeros {
public static void main(String[] args) throws NumberFormatException,
IOException{
BufferedReader Br=new BufferedReader(new
InputStreamReader(System.in));
double d=0,b=0,c=0;
int a;
System.out.println("Este programa realiza las 4 operaciones
fundamentales");
}
System.out.println("El resultado es: "+d);
}
}
import java.io.*;
public class ClubDelCampo {
public static void main(String[] args) throws IOException {
BufferedReader Br=new BufferedReader(new
InputStreamReader(System.in));
String nom;
int a,b,c,d,e,f,g,h,i,j,k=0,x=0,t,s=1;
double y=0;
int l=2014;
while (s==1){
System.out.println("Bienvenido al sistema de socios del Club Del
Campo");
if(t>20)
k=50;
if(t<=40)
if(t>30)
k=100;
if(t<=50)
if(t>40)
k=150;
if(t>50)
k=200;
System.out.println("Ingrese la
categoria en la que se encuentra el socio segun su ao de afiliacion");
System.out.println("1.- A(1964System.out.println("2.-B(1969System.out.println("3.-C(1974System.out.println("4.-D(1979System.out.println("5.-E(2004System.out.println("6.-F(2009System.out.println("7.-G(2014-
BONO DE 0%)");
x=Integer.parseInt(Br.readLine());
switch (x){
case 1:
y=k+(k*0.30);
break;
case 2:
y=k+(k*0.25);
break;
case 3:
y=k+(k*0.20);
break;
case 4:
y=k+(k*0.15);
break;
case 5:
y=k+(k*0.10);
break;
case 6:
y=k+(k*0.5);
break;
case 7:
y=k;
break;
}
System.out.println("El bono del socio " +nom+ " con codigo # "
import java.io.*;
public class Vector {
public static void main(String[] args) throws IOException{
BufferedReader Br=new BufferedReader(new
InputStreamReader(System.in));
int nElementos;
int[]m = new int[3];
m[0]=1;
m[1]=2;
m[2]=3;
import java.io.*;
public class Numeros {
public static void main(String[] args) throws IOException {
BufferedReader s=new BufferedReader(new InputStreamReader(System.in));
int A[],i,n;
System.out.print("Ingrese la cantidad de numeros del cual desea el vector: ");
n = Integer.parseInt(s.readLine());
A = new int [n];
for(i=0;i<n;i++)
{
System.out.print("Ingrese un numero: ");
A[i] = Integer.parseInt(s.readLine());
}
System.out.println("el vector es");
for(i=0;i<n;i++)
{
System.out.println(A[i]);
}
}
}
import java.io.*;
public class Vector1 {
static BufferedReader br = new BufferedReader(new InputStreamReader
(System.in));
public static void main(String[] args) throws IOException{
int x;
System.out.println("INGRESE LA CANTIDAD DE ELEMENTOS
DEL VECTOR");
x=Integer.parseInt(br.readLine());
int m[]=new int[x];
System.out.println("Ingrese los elementos");
for(int i=0;i<x;i++){
System.out.print(" a[" + i + "] =");
m[i]=Integer.parseInt(br.readLine());
}
System.out.println("El vector es : ");
for(int i=0;i<x;i++){
System.out.print(" " + m[i]);
}
for (int i=1;i<x;i++){
for(int j=0;j<i;j++){
if(m[i]<m[j]){
int B;
B=m[j];
m[j]=m[i];
m[i]=B;
}
}
}
System.out.println("\nEl vector ordenado es : ");
for(int i=0;i<x;i++){
System.out.print(" " + m[i]);
}
}
}
import java.io.*;
public class Mayor {
private int arreglo[]; // Atributo de la clase. Arreglo de tipo INT
/* Constructor sin paramentros. Lo que hace es establecer el tamao del
* arreglo en 20 elementos y cargarlo con numeros del 0 al 10 generados
* al azar.
*/
public Mayor()
{
arreglo = new int[20];
for(int i=0; i<arreglo.length; i++)
{
arreglo[i] = (int)(Math.random()*11);
System.out.println(arreglo[i]);
}
}
/* Metodo calcularMenor(): Genera una variable local y la inicializa con
* el valor del primer elemento del arreglo. Despues compara ese valor contra
* todos los elementos del arreglo. Si alguno es MENOR que el actual, entonces
* almacena ese valor en la variable resultado. Al final devuelve el valor
* del MENOR elemento del arreglo
*/
public int calcularMenor()
{
int resultado = arreglo[0];
for(int i=0; i<arreglo.length; i++)
{
if(arreglo[i] < resultado)
{
resultado = arreglo[i];
}
}
return resultado;
}
/* Metodo calcularMayor(): Genera una variable local y la inicializa con
* el valor del primer elemento del arreglo. Despues compara ese valor contra
* todos los elementos del arreglo. Si alguno es MAYOR que el actual, entonces
* almacena ese valor en la variable resultado. Al final devuelve el valor
* del MAYOR elemento del arreglo
*/
public int calcularMayor()
{
int resultado = arreglo[0];
for(int i=0; i<arreglo.length; i++)
{
if(arreglo[i] > resultado)
{
resultado = arreglo[i];
}
}
return resultado;
}
/* Metodo calcularPromedio(): Genera una variable local de tipo float llamada
* "resultado".Luego recorre el arreglo y acumula dentro de la variable el
* valor de todos los elementos del arreglo. Una vez que termino con todo el
* arreglo, divide la suma total de todos los valores por la cantidad de
* elementos que tiene el arreglo.
*/
public double calcularPromedio()
{
double resultado = 0;
int cantidad_numeros = 0;
for(int i=0; i<arreglo.length; i++)
{
resultado += arreglo[i];
cantidad_numeros ++;
}
resultado = (resultado / cantidad_numeros);
return resultado;
}
}
Meses del Ao
import java.io.*;
public class Meses {
public static void main(String[] args){
BufferedReader br = new BufferedReader(new InputStreamReader
(System.in));
String
Enero,Febrero,Marzo,Abril,Mayo,Junio,Julio,Agosto,Septiembre,Octubre,Noviembre,Di
ciembre;
System.out.println(" A continuacion el programa muestra los meses
del ao y sus respectivos numeros de dias ");
String x[]=new String[12];
x[0]="Enero";
x[1]="Febrero";
x[2]="Marzo";
x[3]="Abril";
x[4]="Mayo";
x[5]="Junio";
x[6]="Julio";
x[7]="Agosto";
x[8]="Septiembre";
x[9]="Octubre";
x[10]="Noviembre";
x[11]="Diciembre";
int y[]=new int[12];
y[0]=31;
y[1]=28;
y[2]=31;
y[3]=30;
y[4]=31;
y[5]=30;
y[6]=31;
y[7]=31;
y[8]=30;
y[9]=31;
y[10]=30;
y[11]=31;
for(int i=0;i<12;i++)
System.out.println ( "El mes " +x[i]+ " tiene " +y[i]+ " dias ");
Matriz
import java.io.*;
public class Matriz {
public static void main(String[] args) throws IOException{
BufferedReader br=new BufferedReader (new
InputStreamReader(System.in));
int c=5,a=1;
int [][] numM=new int [c][c];
for(int i=0;i<c;i++){
for(int j=0;j<c;j++){
numM[i][j]=a;
a=a+1;
}
}
System.out.println("La matriz es:");
for(int i=0;i<c;i++){
for(int j=0;j<c;j++){
System.out.print(numM[i][j]+"\t");
}
System.out.println(" ");
}
}
if (i==j+1)
a=1;
else{
a=0;
}
}
}
System.out.println("La matriz es:");
for(int i=0;i<c;i++){
for(int j=0;j<c;j++){
System.out.print(numM[i][j]+"\t");
}
System.out.println(" ");
}
}
import java.io.*;
public class DiagonalSecundaria {
public static void main(String[] args) throws IOException{
BufferedReader br=new BufferedReader (new
InputStreamReader(System.in));
int c=0,a=1;
System.out.println("Ingrese el numero de la matriz:");
c= Integer.parseInt(br.readLine());
int [][] numM=new int [c][c];
for(int i=0;i<c;i++){
for(int j=0;j<c;j++){
numM[i][j]=a;
if (i==j+1)
a=1;
else{
a=0;
}
}
System.out.println("La matriz es:");
for(int i=0;i<c;i++){
for(int j=0;j<c;j++){
System.out.print(numM[i][j]+"\t");
}
System.out.println(" ");
}
}
import java.io.*;
public class der {
}
static void desplegar() throws IOException{
System.out.println("EL NOMBRE ES: "+nombre);
System.out.println("LA EDAD ES: "+edad);
}
public static void main(String[] args) throws IOException {
leer();
desplegar();
}
import java.io.*;
public class UsuariosBanco {
static
static
static
static
String nombre;
double montoini,montofin,deudaact;
double cuota1,cuota2,cuota3,cuota4,cuota5,aporte;
int a=1,c=0,n;
CALCULAR ");
PRESTAMO ");
cuota1=Double.parseDouble(b.readLine());
double m[]=new double[double cuota1];
for(int i=0;i<5;i++);
x[4]="C3";
x[5]="C4";
x[6]="C5";
x[7]="TOTAL PAGADO";
x[8]="TOTAL DEUDA";
int y[]=new int[12];
y[0]=31;
y[1]=28;
y[2]=31;
y[3]=30;
y[4]=31;
y[5]=30;
y[6]=31;
y[7]=31;
montofin=montoini+(montoini*0.15);
aporte=cuota1+cuota2+cuota3+cuota4+cuota5;
deudaact=(montofin-aporte);
}
static void desplegar() throws IOException{
System.out.println(
);
}
public static void main(String[] args) throws IOException {
leer();
desplegar();
}
}
import java.io.*;
public class met1 {
// Mtodo que calcula y devuelve la suma y recibe 2 valores
(parmetros)
static double suma(double x ,double y){
double resp;
resp= x+y;
return resp;
}
// Mtodo que devuelve la resta y recibe 2 valores
(parmetros)
static double resta(double x ,double y){
return (x-y);
}
// Mtodo que devuelve la divisin y recibe 2 valores
(parmetros)
}
System.out.println("INGRESE LOS NUMEROS QUE COMPONEN A
LA SEGUNDA MATRIZ B ");
for(int i=0;i<n;i++){
for(int j=0; j<n;j++ ){
System.out.print("Escribir valor " + i + " ,
" + j + " : ");
matb[i][j]=Integer.parseInt(matriz.readLine());
}
}
System.out.println("LA MATRIZ B ES:" );
for(int i=0;i<n;i++){
for(int j=0; j<n;j++ ){
System.out.print(+mata[i][j]+"\t" );
}
System.out.println("");
}
for (int i=0; i<n; i++){
for (int j=0; j<n; j++){
matc [i][j]= mata[i][j]+matb[i][j];
}
}
for (int i=0; i<n; i++){
for (int j=0; j<n; j++){
matc [i][j]= mata[i][j]-matb[i][j];
}
}
System.out.println("La suma de la matriz A+B=C");
for(int i=0;i<n;i++){
for(int j=0;j<n;j++){
System.out.print (+matc[i][j]+"\t");
}
System.out.println("");
}
System.out.println("La resta de la matriz A-B=D");
for(int i=0;i<n;i++){
for(int j=0;j<n;j++){
System.out.print (+matd[i][j]+"\t");
}
System.out.println("");
}
}
}