import java.io.*;
public class Alumno2
{
public static void main(String args[])
{
InputStreamReader entrada = new InputStreamReader(System.in);
BufferedReader flujoEntrada = new BufferedReader(entrada);
String datoEntrada;
String nombreAlum="", observacion;
float calif1=0, calif2=0, calif3=0, calif4=0, promedio;
System.out.println("\n CALCULA PROMEDIO DE UN ALUMNO\n");
try
{
System.out.println("------------ Entrada de datos ------------");
System.out.print("Teclee nombre: ");
datoEntrada = flujoEntrada.readLine();
nombreAlum = datoEntrada;
System.out.print("Teclee calificacion 1: ");
datoEntrada = flujoEntrada.readLine();
calif1 = Float.parseFloat(datoEntrada);
System.out.print("Teclee calificacion 2: ");
datoEntrada = flujoEntrada.readLine();
calif2 = Float.parseFloat(datoEntrada);
System.out.print("Teclee calificacion 3: ");
datoEntrada = flujoEntrada.readLine();
calif3 = Float.parseFloat(datoEntrada);
System.out.print("Teclee calificacion 4: ");
datoEntrada = flujoEntrada.readLine();
calif4 = Float.parseFloat(datoEntrada);
}
catch (IOException error)
{
System.err.println("Error " + error.getMessage());
}
promedio = (calif1 + calif2 + calif3 + calif4) / 4;
if (promedio >= 60)
observacion = "Aprobado";
else
observacion = "Reprobado";
System.out.println("\n----------------- Salida -----------------");
System.out.println("Nombre = " + nombreAlum);
System.out.println("Promedio = " + promedio);
System.out.println("Observacion = " + observacion);
}
}
--------------------------------------------------------------------------------------------------------------------------------
import java.io.*;
public class Angulo4
{
public static void main(String args[])
{
InputStreamReader entrada = new InputStreamReader(System.in);
BufferedReader flujoEntrada = new BufferedReader(entrada);
String datoEntrada;
double angulo=0, senAng, cosAng, angRadianes, angGrados;
char resp=' ';
System.out.println("\nREALIZA CALCULOS LOGARITMICOS\n");
try
{
System.out.println("------------ Entrada de datos ------------");
System.out.println("¿En que tiene el tamaño del angulo?");
System.out.print("¿En Grados (G), Radianes (R)?: ");
resp = (char)System.in.read();
System.in.skip(2);
System.out.print("Teclee tamaño del angulo: ");
datoEntrada = flujoEntrada.readLine();
angulo = Double.parseDouble(datoEntrada);
}
catch (IOException error)
{
System.err.println("Error " + error.getMessage());
}
if (resp == 'G' || resp == 'g')
{
angRadianes = angulo * (Math.PI/180);
System.out.println("Equivalen a " + angRadianes + " Radianes");
senAng = Math.sin(angRadianes);
cosAng = Math.cos(angRadianes);
}
else
{
angGrados = angulo * (180/Math.PI);
System.out.println("Equivalen a " + angGrados + " Grados");
senAng = Math.sin(angulo);
cosAng = Math.cos(angulo);
}
System.out.println("\n----------------- Salida -----------------");
System.out.println("Seno = " + senAng);
System.out.println("Coseno = " + cosAng);
}
}
--------------------------------------------------------------------------------------------------------------------------------
import java.io.*;
public class AngulosIgualesDife
{
public static void main(String args[])
{
InputStreamReader entrada = new InputStreamReader(System.in);
BufferedReader flujoEntrada = new BufferedReader(entrada);
String datoEntrada;
float anguloA = 0F, anguloB = 0F;
System.out.println("\nIMPRIME SI LOS ANGULOS SON IGUALES O DIFERENTES\n");
try
{
System.out.println("------------ Entrada de datos ------------");
System.out.print("Teclee angulo A: ");
datoEntrada = flujoEntrada.readLine();
anguloA = Float.parseFloat(datoEntrada);
System.out.print("Teclee angulo B: ");
datoEntrada = flujoEntrada.readLine();
anguloB = Float.parseFloat(datoEntrada);
}
catch (IOException error)
{
System.err.println("Error " + error.getMessage());
}
System.out.println("\n----------------- Salida -----------------");
if (anguloA == anguloB)
{
System.out.println("Los angulos son iguales");
if (anguloA < 90)
System.out.println("son Agudos");
if (anguloA == 90)
System.out.println("son RectoS");
if (anguloA > 90 && anguloA < 180)
System.out.println("son Obtusos");
if (anguloA == 0 || anguloA == 180 || anguloA == 360)
System.out.println("son Llanos o Planos");
if (anguloA > 180 && anguloA < 360)
System.out.println("son Concavos");
}
else
{
System.out.println("Los angulos son diferentes");
if (anguloA < 90)
System.out.println("El angulo A es Agudo");
if (anguloA == 90)
System.out.println("El angulo A es Recto");
if (anguloA > 90 && anguloA < 180)
System.out.println("El angulo A es Obtuso");
if (anguloA == 0 || anguloA == 180 || anguloA == 360)
System.out.println("El angulo A es Llano o Plano");
if (anguloA > 180 && anguloA < 360)
System.out.println("El angulo A es Concavo");
if (anguloB < 90)
System.out.println("El angulo B es Agudo");
if (anguloB == 90)
System.out.println("El angulo B es Recto");
if (anguloB > 90 && anguloB < 180)
System.out.println("El angulo B es Obtuso");
if (anguloB == 0 || anguloB == 180 || anguloB == 360)
System.out.println("El angulo B es Llano o Plano");
if (anguloB > 180 && anguloB < 360)
System.out.println("El angulo B es Concavo");
}
}
}
------------------------------------------------------------------------------------------------------------------------------------
import java.io.*;
public class Cliente1
{
public static void main(String args[])
{
InputStreamReader entrada = new InputStreamReader(System.in);
BufferedReader flujoEntrada = new BufferedReader(entrada);
String datoEntrada;
String nombreClie="";
int tipoClie=0, cantidad=0;
float precioUni=0, subTotal, descuento=0, totalPagar;
System.out.println("\n REALIZA CALCULOS DE UN CLIENTE\n");
try
{
System.out.println("------------ Entrada de datos ------------");
System.out.print("Teclee nombre: ");
datoEntrada = flujoEntrada.readLine();
nombreClie = datoEntrada;
System.out.print("Teclee tipo de cliente (1-4): ");
datoEntrada = flujoEntrada.readLine();
tipoClie = Integer.parseInt(datoEntrada);
System.out.print("Teclee cantidad de piezas compradas: ");
datoEntrada = flujoEntrada.readLine();
cantidad = Integer.parseInt(datoEntrada);
System.out.print("Teclee precio unitario: ");
datoEntrada = flujoEntrada.readLine();
precioUni = Float.parseFloat(datoEntrada);
}
catch (IOException error)
{
System.err.println("Error " + error.getMessage());
}
subTotal = cantidad * precioUni;
switch (tipoClie)
{
case 1:
descuento = subTotal * 0.05F;
break;
case 2:
descuento = subTotal * 0.08F;
break;
case 3:
descuento = subTotal * 0.12F;
break;
case 4:
descuento = subTotal * 0.15F;
break;
}
totalPagar = subTotal - descuento;
System.out.println("\n----------------- Salida -----------------");
System.out.println("Nombre = " + nombreClie);
System.out.println("Subtotal = " + subTotal);
System.out.println("Descuento = " + descuento);
System.out.println("Total a pagar = " + totalPagar);
}
}
-----------------------------------------------------------------------------------------------------------------------------------
import java.io.*;
public class Cuadratica1
{
public static void main(String args[])
{
InputStreamReader entrada = new InputStreamReader(System.in);
BufferedReader flujoEntrada = new BufferedReader(entrada);
String datoEntrada;
double a=0, b=0, c=0, raizUnica, parteReal, parteImaginaria,
raizReal1, raizReal2;
System.out.println("\nREALIZA CALCULOS CON LA ECUACION CUADRATICA\n");
try
{
System.out.println("------------ Entrada de datos ------------");
System.out.print("Teclee Coeficiente A: ");
datoEntrada = flujoEntrada.readLine();
a = Double.parseDouble(datoEntrada);
System.out.print("Teclee Coeficiente B: ");
datoEntrada = flujoEntrada.readLine();
b = Double.parseDouble(datoEntrada);
System.out.print("Teclee Coeficiente C: ");
datoEntrada = flujoEntrada.readLine();
c = Double.parseDouble(datoEntrada);
}
catch (IOException error)
{
System.err.println("Error " + error.getMessage());
}
System.out.println("\n----------------- Salida -----------------");
if ((Math.pow(b,2)-4*a*c) == 0)
{
raizUnica = -b/(2*a);
System.out.println("Tiene raiz unica");
System.out.println("Raiz unica = " + raizUnica);
}
else
if ((Math.pow(b,2)-4*a*c) < 0)
{
parteReal = -b/(2*a);
parteImaginaria = Math.sqrt(Math.abs(Math.pow(b,2)-4*a*c))/(2*a);
System.out.println("Tiene raices complejas");
System.out.println(" Parte real Parte imaginaria");
System.out.println(parteReal + " + " + parteImaginaria);
System.out.println(parteReal + " - " + parteImaginaria);
}
else
{
raizReal1 = -b + Math.sqrt(Math.pow(b,2)-4*a*c)/(2*a);
raizReal2 = -b - Math.sqrt(Math.pow(b,2)-4*a*c)/(2*a);
System.out.println("Tiene raices reales");
System.out.println("Raiz real 1 = " + raizReal1);
System.out.println("Raiz real 2 = " + raizReal2);
}
}
}
---------------------------------------------------------------------------------------------------------------------------------
import java.io.*;
public class DiceDia1
{
public static void main(String args[])
{
InputStreamReader entrada = new InputStreamReader(System.in);
BufferedReader flujoEntrada = new BufferedReader(entrada);
String datoEntrada;
int numDia=0;
System.out.println("\n DICE NOMBRE DEL DIA\n");
try
{
System.out.println("------------ Entrada del dato ------------");
System.out.print("Teclee numero de dia (1-7): ");
datoEntrada = flujoEntrada.readLine();
numDia = Integer.parseInt(datoEntrada);
}
catch (IOException error)
{
System.err.println("Error " + error.getMessage());
}
System.out.print("\nEl dia " + numDia + " es ");
switch (numDia)
{
case 1:
System.out.println("Domingo");
break;
case 2:
System.out.println("Lunes");
break;
case 3:
System.out.println("Martes");
break;
case 4:
System.out.println("Miercoles");
break;
case 5:
System.out.println("Jueves");
break;
case 6:
System.out.println("Viernes");
break;
case 7:
System.out.println("Sabado");
break;
default:
System.out.println("No esta en el rango de 1 a 7");
}
}
}
----------------------------------------------------------------------------------------------------------------------------------
import java.io.*;
public class DiceParImpar
{
public static void main(String args[])
{
InputStreamReader entrada = new InputStreamReader(System.in);
BufferedReader flujoEntrada = new BufferedReader(entrada);
String datoEntrada;
int num=0;
System.out.println("\n DICE SI ES PAR O IMPAR\n");
try
{
System.out.println("------------ Entrada del dato ------------");
System.out.print("Teclee un numero entero (0-9): ");
datoEntrada = flujoEntrada.readLine();
num = Integer.parseInt(datoEntrada);
}
catch (IOException error)
{
System.err.println("Error " + error.getMessage());
}
switch (num)
{
case 0:
case 2:
case 4:
case 6:
case 8:
System.out.println("\nEl numero " + num + " es " + "Par");
break;
case 1:
case 3:
case 5:
case 7:
case 9:
System.out.println("\nEl numero " + num + " es " + "Impar");
break;
default:
System.out.println("\nNo esta en el rango de 0 a 9");
}
}
}
-------------------------------------------------------------------------------------------------------------------------------------
import java.io.*;
public class DiceVocal
{
public static void main(String args[])
{
char car=' ';
System.out.println("\n DICE SI ES VOCAL O NO\n");
try
{
System.out.println("------------ Lectura del dato ------------");
System.out.print("Teclee un caracter: ");
car = (char)System.in.read();
}
catch (IOException error)
{
System.err.println("Error " + error.getMessage());
}
switch (car)
{
case 'a':
case 'e':
case 'i':
case 'o':
case 'u':
System.out.println(car + " es vocal minuscula");
break;
case 'A':
case 'E':
case 'I':
case 'O':
case 'U':
System.out.println(car + " es vocal mayuscula");
break;
default:
System.out.println(car + " no es vocal");
}
}
}
--------------------------------------------------------------------------------------------------------------------------------------
import java.io.*;
public class Empleado2
{
public static void main(String args[])
{
InputStreamReader entrada = new InputStreamReader(System.in);
BufferedReader flujoEntrada = new BufferedReader(entrada);
String datoEntrada;
String nombreEmp="";
int horasTrab=0;
float cuotaHora=0;
float sueldo;
System.out.println("\n CALCULA SUELDO DE EMPLEADO DOBLE\n");
try
{
System.out.println("------------ Entrada de datos ------------");
System.out.print("Teclee nombre: ");
datoEntrada = flujoEntrada.readLine();
nombreEmp = datoEntrada;
System.out.print("Teclee horas trabajadas: ");
datoEntrada = flujoEntrada.readLine();
horasTrab = Integer.parseInt(datoEntrada);
System.out.print("Teclee cuota por hora: ");
datoEntrada = flujoEntrada.readLine();
cuotaHora = Float.parseFloat(datoEntrada);
}
catch (IOException error)
{
System.err.println("Error " + error.getMessage());
}
if (horasTrab <= 40)
sueldo = horasTrab * cuotaHora;
else
sueldo = (40*cuotaHora) + ((horasTrab-40)*(cuotaHora*2));
System.out.println("\n----------------- Salida -----------------");
System.out.println("Nombre = " + nombreEmp);
System.out.println("Sueldo = " + sueldo);
}
}
-----------------------------------------------------------------------------------------------------------------------------------
import java.io.*;
public class Empleado3
{
public static void main(String args[])
{
InputStreamReader entrada = new InputStreamReader(System.in);
BufferedReader flujoEntrada = new BufferedReader(entrada);
String datoEntrada;
String nombreEmp="";
int horasTrab=0;
float cuotaHora=0;
float sueldo;
System.out.println("\n CALCULA SUELDO DE EMPLEADO TRIPLE\n");
try
{
System.out.println("------------ Entrada de datos ------------");
System.out.print("Teclee nombre: ");
datoEntrada = flujoEntrada.readLine();
nombreEmp = datoEntrada;
System.out.print("Teclee horas trabajadas: ");
datoEntrada = flujoEntrada.readLine();
horasTrab = Integer.parseInt(datoEntrada);
System.out.print("Teclee cuota por hora: ");
datoEntrada = flujoEntrada.readLine();
cuotaHora = Float.parseFloat(datoEntrada);
}
catch (IOException error)
{
System.err.println("Error " + error.getMessage());
}
if (horasTrab <= 40)
sueldo = horasTrab * cuotaHora;
else
if (horasTrab <= 50)
sueldo = (40*cuotaHora) + ((horasTrab-40)*(cuotaHora*2));
else
sueldo = (40*cuotaHora) + (10*cuotaHora*2)
+ ((horasTrab-50)*(cuotaHora*3));
System.out.println("\n----------------- Salida -----------------");
System.out.println("Nombre = " + nombreEmp);
System.out.println("Sueldo = " + sueldo);
}
}
-----------------------------------------------------------------------------------------------------------------------------------
import java.io.*;
public class Empleado4
{
public static void main(String args[])
{
InputStreamReader entrada = new InputStreamReader(System.in);
BufferedReader flujoEntrada = new BufferedReader(entrada);
String datoEntrada;
String nombreEmp="";
int horasTrab=0;
float cuotaHora=0;
float sueldo;
System.out.println("\n CALCULA SUELDO DE EMPLEADO\n");
try
{
System.out.println("------------ Entrada de datos ------------");
System.out.print("Teclee nombre: ");
datoEntrada = flujoEntrada.readLine();
nombreEmp = datoEntrada;
System.out.print("Teclee horas trabajadas: ");
datoEntrada = flujoEntrada.readLine();
horasTrab = Integer.parseInt(datoEntrada);
System.out.print("Teclee cuota por hora: ");
datoEntrada = flujoEntrada.readLine();
cuotaHora = Float.parseFloat(datoEntrada);
}
catch (IOException error)
{
System.err.println("Error " + error.getMessage());
}
sueldo = horasTrab * cuotaHora;
if (horasTrab > 40)
sueldo = sueldo + (sueldo * 0.05F);
System.out.println("\n----------------- Salida -----------------");
System.out.println("Nombre = " + nombreEmp);
System.out.println("Sueldo = " + sueldo);
}
}
-------------------------------------------------------------------------------------------------------------------------------------
import java.io.*;
public class EquivalenciasPies
{
public static void main(String args[])
{
InputStreamReader entrada = new InputStreamReader(System.in);
BufferedReader flujoEntrada = new BufferedReader(entrada);
String datoEntrada;
double metros=0, pies=0, yardas=0, pulgadas=0;
char resp=' ';
System.out.println("\nCALCULA EQUIVALENCIAS YARDAS PIES PLGADAS METROS\n");
try
{
System.out.println("------------ Entrada de datos ------------");
System.out.println("¿Que desea convertir?");
System.out.print("¿Metros (M), Yardas (Y), Pies (P), Pulgadas (U)?: ");
resp = (char)System.in.read();
System.in.skip(2);
}
catch (IOException error)
{
System.err.println("Error " + error.getMessage());
}
if (resp == 'M' || resp == 'm')
{
try
{
System.out.print("Teclee numero de metros: ");
datoEntrada = flujoEntrada.readLine();
metros = Double.parseDouble(datoEntrada);
}
catch (IOException error)
{
System.err.println("Error " + error.getMessage());
}
pulgadas = (metros * 100)/2.54;
pies = pulgadas/12;
yardas = pies/3;
System.out.println("\n----------------- Salida -----------------");
System.out.println(metros + " Metros equivalen a ");
System.out.println(pulgadas + " Pulgadas");
System.out.println(pies + " Pies");
System.out.println(yardas + " Yardas");
}
if (resp == 'Y' || resp == 'y')
{
try
{
System.out.print("Teclee numero de yardas: ");
datoEntrada = flujoEntrada.readLine();
yardas = Double.parseDouble(datoEntrada);
}
catch (IOException error)
{
System.err.println("Error " + error.getMessage());
}
pies = yardas * 3;
pulgadas = pies * 12;
metros = (pulgadas * 2.54) / 100;
System.out.println("\n----------------- Salida -----------------");
System.out.println(yardas + " Yardas equivalen a ");
System.out.println(pulgadas + " Pulgadas");
System.out.println(pies + " Pies");
System.out.println(metros + " Metros");
}
if (resp == 'P' || resp == 'p')
{
try
{
System.out.print("Teclee numero de pies: ");
datoEntrada = flujoEntrada.readLine();
pies = Double.parseDouble(datoEntrada);
}
catch (IOException error)
{
System.err.println("Error " + error.getMessage());
}
pulgadas = pies * 12;
yardas = pies/3;
metros = (pulgadas * 2.54) / 100;
System.out.println("\n----------------- Salida -----------------");
System.out.println(pies + " Pies equivalen a ");
System.out.println(pulgadas + " Pulgadas");
System.out.println(yardas + " Yardas");
System.out.println(metros + " Metros");
}
if (resp == 'U' || resp == 'u')
{
try
{
System.out.print("Teclee numero de pulgadas: ");
datoEntrada = flujoEntrada.readLine();
pulgadas = Double.parseDouble(datoEntrada);
}
catch (IOException error)
{
System.err.println("Error " + error.getMessage());
}
pies = pulgadas/12;
yardas = pies/3;
metros = (pulgadas * 2.54) / 100;
System.out.println("\n----------------- Salida -----------------");
System.out.println(pulgadas + " Pulgadas equivalen a ");
System.out.println(pies + " Pies");
System.out.println(yardas + " Yardas");
System.out.println(metros + " Metros");
}
}
}
--------------------------------------------------------------------------------------------------------------------------------------
import java.io.*;
public class LeyNewton1
{
public static void main(String args[])
{
InputStreamReader entrada = new InputStreamReader(System.in);
BufferedReader flujoEntrada = new BufferedReader(entrada);
String datoEntrada;
double f=0, a=0, m=0;
char resp=' ';
System.out.println("\nREALIZA CALCULOS CON LA SEGUNDA LEY NEWTON\n");
try
{
System.out.println("------------ Entrada de datos ------------");
System.out.println("¿Que desea calcular?");
System.out.print("¿Fuerza (F), Aceleracion (A), Masa (M)?: ");
resp = (char)System.in.read();
System.in.skip(2);
}
catch (IOException error)
{
System.err.println("Error " + error.getMessage());
}
if (resp == 'F' || resp == 'f')
{
try
{
System.out.print("Teclee Masa: ");
datoEntrada = flujoEntrada.readLine();
m = Double.parseDouble(datoEntrada);
System.out.print("Teclee Aceleracion: ");
datoEntrada = flujoEntrada.readLine();
a = Double.parseDouble(datoEntrada);
}
catch (IOException error)
{
System.err.println("Error " + error.getMessage());
}
f = m * a;
System.out.println("\n----------------- Salida -----------------");
System.out.println("Fuerza = " + f);
}
if (resp == 'A' || resp == 'a')
{
try
{
System.out.print("Teclee Masa: ");
datoEntrada = flujoEntrada.readLine();
m = Double.parseDouble(datoEntrada);
System.out.print("Teclee Fuerza: ");
datoEntrada = flujoEntrada.readLine();
f = Double.parseDouble(datoEntrada);
}
catch (IOException error)
{
System.err.println("Error " + error.getMessage());
}
a = f / m;
System.out.println("\n----------------- Salida -----------------");
System.out.println("Aceleracion = " + a);
}
if (resp == 'M' || resp == 'm')
{
try
{
System.out.print("Teclee Fuerza: ");
datoEntrada = flujoEntrada.readLine();
f = Double.parseDouble(datoEntrada);
System.out.print("Teclee Aceleracion: ");
datoEntrada = flujoEntrada.readLine();
a = Double.parseDouble(datoEntrada);
}
catch (IOException error)
{
System.err.println("Error " + error.getMessage());
}
m = f / a;
System.out.println("\n----------------- Salida -----------------");
System.out.println("Masa = " + m);
}
}
}
------------------------------------------------------------------------------------------------------------------------------------
import java.io.*;
public class Mayor2Numeros
{
public static void main(String args[])
{
InputStreamReader entrada = new InputStreamReader(System.in);
BufferedReader flujoEntrada = new BufferedReader(entrada);
String datoEntrada;
int a=0, b=0;
System.out.println("\n IMPRIME EL MAYOR DE 2 NUMEROS\n");
try
{
System.out.println("------------ Entrada de datos ------------");
System.out.print("Teclee numero 1: ");
datoEntrada = flujoEntrada.readLine();
a = Integer.parseInt(datoEntrada);
System.out.print("Teclee numero 2: ");
datoEntrada = flujoEntrada.readLine();
b = Integer.parseInt(datoEntrada);
}
catch (IOException error)
{
System.err.println("Error " + error.getMessage());
}
System.out.println("\n----------------- Salida -----------------");
if (a > b)
System.out.println("El mayor es " + a);
else
System.out.println("El mayor es " + b);
}
}
----------------------------------------------------------------------------------------------------------------------------------
import java.io.*;
public class Mayor3Numeros1
{
public static void main(String args[])
{
InputStreamReader entrada = new InputStreamReader(System.in);
BufferedReader flujoEntrada = new BufferedReader(entrada);
String datoEntrada;
int a=0, b=0, c=0;
System.out.println("\n IMPRIME EL MAYOR DE 3 NUMEROS\n");
try
{
System.out.println("------------ Entrada de datos ------------");
System.out.print("Teclee numero 1: ");
datoEntrada = flujoEntrada.readLine();
a = Integer.parseInt(datoEntrada);
System.out.print("Teclee numero 2: ");
datoEntrada = flujoEntrada.readLine();
b = Integer.parseInt(datoEntrada);
System.out.print("Teclee numero 3: ");
datoEntrada = flujoEntrada.readLine();
c = Integer.parseInt(datoEntrada);
}
catch (IOException error)
{
System.err.println("Error " + error.getMessage());
}
System.out.println("\n----------------- Salida -----------------");
if (a > b)
if (a > c)
System.out.println("El mayor es " + a);
else
System.out.println("El mayor es " + c);
else
if (b > c)
System.out.println("El mayor es " + b);
else
System.out.println("El mayor es " + c);
}
}
-------------------------------------------------------------------------------------------------------------------------------------
import java.io.*;
public class Mayor3Numeros2
{
public static void main(String args[])
{
InputStreamReader entrada = new InputStreamReader(System.in);
BufferedReader flujoEntrada = new BufferedReader(entrada);
String datoEntrada;
int a=0, b=0, c=0;
System.out.println("\n IMPRIME EL MAYOR DE 3 NUMEROS\n");
try
{
System.out.println("------------ Entrada de datos ------------");
System.out.print("Teclee numero 1: ");
datoEntrada = flujoEntrada.readLine();
a = Integer.parseInt(datoEntrada);
System.out.print("Teclee numero 2: ");
datoEntrada = flujoEntrada.readLine();
b = Integer.parseInt(datoEntrada);
System.out.print("Teclee numero 3: ");
datoEntrada = flujoEntrada.readLine();
c = Integer.parseInt(datoEntrada);
}
catch (IOException error)
{
System.err.println("Error " + error.getMessage());
}
System.out.println("\n----------------- Salida -----------------");
if (a > b && a > c)
System.out.println("El mayor es " + a);
if (b > a && b > c)
System.out.println("El mayor es " + b);
if (c > a && c > b)
System.out.println("El mayor es " + c);
}
}
---------------------------------------------------------------------------------------------------------------------------------
import java.io.*;
public class Mayor3Numeros3
{
public static void main(String args[])
{
InputStreamReader entrada = new InputStreamReader(System.in);
BufferedReader flujoEntrada = new BufferedReader(entrada);
String datoEntrada;
int a=0, b=0, c=0;
System.out.println("\n IMPRIME EL MAYOR DE 3 NUMEROS\n");
try
{
System.out.println("------------ Entrada de datos ------------");
System.out.print("Teclee numero 1: ");
datoEntrada = flujoEntrada.readLine();
a = Integer.parseInt(datoEntrada);
System.out.print("Teclee numero 2: ");
datoEntrada = flujoEntrada.readLine();
b = Integer.parseInt(datoEntrada);
System.out.print("Teclee numero 3: ");
datoEntrada = flujoEntrada.readLine();
c = Integer.parseInt(datoEntrada);
}
catch (IOException error)
{
System.err.println("Error " + error.getMessage());
}
System.out.println("\n----------------- Salida -----------------");
if (a > b && a > c)
System.out.println("El mayor es " + a);
else
if (b > c)
System.out.println("El mayor es " + b);
else
System.out.println("El mayor es " + c);
}
}
------------------------------------------------------------------------------------------------------------------------------------
import java.io.*;
public class Mayor4Numeros1
{
public static void main(String args[])
{
InputStreamReader entrada = new InputStreamReader(System.in);
BufferedReader flujoEntrada = new BufferedReader(entrada);
String datoEntrada;
int a=0, b=0, c=0, d=0;
System.out.println("\n IMPRIME EL MAYOR DE 4 NUMEROS\n");
try
{
System.out.println("------------ Entrada de datos ------------");
System.out.print("Teclee numero 1: ");
datoEntrada = flujoEntrada.readLine();
a = Integer.parseInt(datoEntrada);
System.out.print("Teclee numero 2: ");
datoEntrada = flujoEntrada.readLine();
b = Integer.parseInt(datoEntrada);
System.out.print("Teclee numero 3: ");
datoEntrada = flujoEntrada.readLine();
c = Integer.parseInt(datoEntrada);
System.out.print("Teclee numero 4: ");
datoEntrada = flujoEntrada.readLine();
d = Integer.parseInt(datoEntrada);
}
catch (IOException error)
{
System.err.println("Error " + error.getMessage());
}
System.out.println("\n----------------- Salida -----------------");
if (a > b && a > c && a > d)
System.out.println("El mayor es " + a);
else
if (b > c && b > d)
System.out.println("El mayor es " + b);
else
if (c > d)
System.out.println("El mayor es " + c);
else
System.out.println("El mayor es " + d);
}
}
----------------------------------------------------------------------------------------------------------------------------------
import java.io.*;
public class Mayor5Numeros1
{
public static void main(String args[])
{
InputStreamReader entrada = new InputStreamReader(System.in);
BufferedReader flujoEntrada = new BufferedReader(entrada);
String datoEntrada;
int a=0, b=0, c=0, d=0, e=0, mayor;
System.out.println("\n IMPRIME EL MAYOR DE 5 NUMEROS\n");
try
{
System.out.println("------------ Entrada de datos ------------");
System.out.print("Teclee numero 1: ");
datoEntrada = flujoEntrada.readLine();
a = Integer.parseInt(datoEntrada);
System.out.print("Teclee numero 2: ");
datoEntrada = flujoEntrada.readLine();
b = Integer.parseInt(datoEntrada);
System.out.print("Teclee numero 3: ");
datoEntrada = flujoEntrada.readLine();
c = Integer.parseInt(datoEntrada);
System.out.print("Teclee numero 4: ");
datoEntrada = flujoEntrada.readLine();
d = Integer.parseInt(datoEntrada);
System.out.print("Teclee numero 5: ");
datoEntrada = flujoEntrada.readLine();
e = Integer.parseInt(datoEntrada);
}
catch (IOException error)
{
System.err.println("Error " + error.getMessage());
}
mayor = a;
if (b > mayor)
mayor = b;
if (c > mayor)
mayor = c;
if (d > mayor)
mayor = d;
if (e > mayor)
mayor = e;
System.out.println("\n----------------- Salida -----------------");
System.out.println("El mayor es " + mayor);
}
}
-----------------------------------------------------------------------------------------------------------------------------------
import java.io.*;
public class TipoAngulo1
{
public static void main(String args[])
{
InputStreamReader entrada = new InputStreamReader(System.in);
BufferedReader flujoEntrada = new BufferedReader(entrada);
String datoEntrada;
float angulo=0F;
System.out.println("\n IMPRIME EL TIPO DE ANGULO\n");
try
{
System.out.println("------------ Entrada del dato ------------");
System.out.print("Teclee angulo: ");
datoEntrada = flujoEntrada.readLine();
angulo = Float.parseFloat(datoEntrada);
}
catch (IOException error)
{
System.err.println("Error " + error.getMessage());
}
System.out.println("\n----------------- Salida -----------------");
if (angulo < 90)
System.out.println("El angulo es Agudo");
if (angulo == 90)
System.out.println("El angulo es Recto");
if (angulo > 90 && angulo < 180)
System.out.println("El angulo es Obtuso");
if (angulo == 0 || angulo == 180 || angulo == 360)
System.out.println("El angulo es Llano o Plano");
if (angulo > 180 && angulo < 360)
System.out.println("El angulo es Concavo");
}
}
-----------------------------------------------------------------------------------------------------------------------------------
import java.io.*;
public class TipoTriangulo
{
public static void main(String args[])
{
InputStreamReader entrada = new InputStreamReader(System.in);
BufferedReader flujoEntrada = new BufferedReader(entrada);
String datoEntrada;
float ladoA=0F, ladoB=0F, ladoC=0F;
System.out.println("\n IMPRIME EL TIPO DE TRIANGULO\n");
try
{
System.out.println("------------ Entrada de datos ------------");
System.out.print("Teclee lado A: ");
datoEntrada = flujoEntrada.readLine();
ladoA = Float.parseFloat(datoEntrada);
System.out.print("Teclee lado B: ");
datoEntrada = flujoEntrada.readLine();
ladoB = Float.parseFloat(datoEntrada);
System.out.print("Teclee lado C: ");
datoEntrada = flujoEntrada.readLine();
ladoC = Float.parseFloat(datoEntrada);
}
catch (IOException error)
{
System.err.println("Error " + error.getMessage());
}
System.out.println("\n----------------- Salida -----------------");
if (ladoA != ladoB && ladoA != ladoC && ladoB != ladoC)
System.out.println("El triangulo es Escaleno");
else
if (ladoA == ladoB && ladoA == ladoC && ladoB == ladoC)
System.out.println("El triangulo es Equilatero");
else
System.out.println("El triangulo es Isosceles");
}
}
lunes, 30 de noviembre de 2009
algoritmos medios (40)
import java.io.*;
public class Cuadratica2
{
public static void main(String args[])
{
double a=0, b=0, c=0, raizUnica, parteReal, parteImaginaria,
raizReal1, raizReal2;
System.out.println("\n REALIZA CALCULOS CON LA ECUACION CUADRATICA\n");
System.out.println(" A B C TIENE RAIZ 1 RAIZ 2");
System.out.println("---------------------------------------------");
for (a=1; a<=5; a++)
{
c = c - a;
b = a - c;
System.out.print(a + " " + b + " " + c);
if ((Math.pow(b,2)-4*a*c) == 0)
{
raizUnica = -b/(2*a);
System.out.println(" Raiz unica " + raizUnica);
}
else
if ((Math.pow(b,2)-4*a*c) < 0)
{
parteReal = -b/(2*a);
parteImaginaria = Math.sqrt(Math.abs(Math.pow(b,2)-4*a*c))/(2*a);
System.out.print(" Raices complejas ");
System.out.println(" Parte real Parte imaginaria");
System.out.println(parteReal + " + " + parteImaginaria);
System.out.println(parteReal + " - " + parteImaginaria);
}
else
{
raizReal1 = -b + Math.sqrt(Math.pow(b,2)-4*a*c)/(2*a);
raizReal2 = -b - Math.sqrt(Math.pow(b,2)-4*a*c)/(2*a);
System.out.print(" Raices reales ");
System.out.println(raizReal1 + " " + raizReal2);
}
}
}
}
--------------------------------------------------------------------------------------------------------------------------------------
import java.io.*;
public class EquivalenciasFahr1
{
public static void main(String args[])
{
float fahrenheit, celsius;
System.out.println("\nCALCULA EQUIVALENCIAS FAHRENHEIT CELSIUS\n");
System.out.println("Fahrenheit Celsius");
System.out.println("-------------------------------");
for (fahrenheit = 1; fahrenheit <= 65; fahrenheit++)
{
celsius = (5F/9F) * (fahrenheit-32);
System.out.println(fahrenheit + " " + celsius);
}
}
}
----------------------------------------------------------------------------------------------------------------------------------
import java.io.*;
public class Factorial1
{
public static void main(String args[])
{
InputStreamReader entrada = new InputStreamReader(System.in);
BufferedReader flujoEntrada = new BufferedReader(entrada);
String datoEntrada;
int num, i, fact;
System.out.println("\nCALCULA EL FACTORIAL DE UN NUMERO\n");
try
{
System.out.println("-------- Entrada del dato --------");
System.out.print("Teclee numero: ");
datoEntrada = flujoEntrada.readLine();
num = Integer.parseInt(datoEntrada);
if (num == 0)
fact = 1;
else
{
fact = 1;
for (i = num; i >= 1; i--)
{
fact = fact * i;
}
}
System.out.println("\n------------- Salida -------------");
System.out.println("Factorial = " + fact);
}
catch (IOException error)
{
System.err.println("Error " + error.getMessage());
}
}
}
-----------------------------------------------------------------------------------------------------------------------------------
import java.io.*;
public class Factoriales1
{
public static void main(String args[])
{
InputStreamReader entrada = new InputStreamReader(System.in);
BufferedReader flujoEntrada = new BufferedReader(entrada);
String datoEntrada;
int n, i, j, fact, num;
System.out.println("\n CALCULA EL FACTORIAL DE N NUMEROS\n");
try
{
System.out.print("¿A cuantos numeros desea calcular factorial?: ");
datoEntrada = flujoEntrada.readLine();
n = Integer.parseInt(datoEntrada);
for (j = 1; j <= n; j++)
{
System.out.println("\n-------- Entrada del dato --------");
System.out.print("Teclee numero: ");
datoEntrada = flujoEntrada.readLine();
num = Integer.parseInt(datoEntrada);
if (num == 0)
fact = 1;
else
{
fact = 1;
for (i = num; i >= 1; i--)
{
fact = fact * i;
}
}
System.out.println("\n------------- Salida -------------");
System.out.println("Factorial = " + fact);
}
}
catch (IOException error)
{
System.err.println("Error " + error.getMessage());
}
}
}
-------------------------------------------------------------------------------------------------------------------------------------
import java.io.*;
public class Factoriales2
{
public static void main(String args[])
{
InputStreamReader entrada = new InputStreamReader(System.in);
BufferedReader flujoEntrada = new BufferedReader(entrada);
String datoEntrada;
int n, i, j, fact, num;
System.out.println("\n CALCULA EL FACTORIAL DE N NUMEROS\n");
try
{
System.out.print("¿A cuantos numeros desea calcular factorial?: ");
datoEntrada = flujoEntrada.readLine();
n = Integer.parseInt(datoEntrada);
j = 0;
do
{
j = j + 1;
System.out.println("\n-------- Entrada del dato --------");
System.out.print("Teclee numero: ");
datoEntrada = flujoEntrada.readLine();
num = Integer.parseInt(datoEntrada);
if (num == 0)
fact = 1;
else
{
fact = 1;
for (i = num; i >= 1; i--)
{
fact = fact * i;
}
}
System.out.println("\n------------- Salida -------------");
System.out.println("Factorial = " + fact);
} while (j != n);
}
catch (IOException error)
{
System.err.println("Error " + error.getMessage());
}
}
}
------------------------------------------------------------------------------------------------------------------------------------
import java.io.*;
public class Fibonacci
{
public static void main(String args[])
{
int i, numero, penultimo, ultimo;
System.out.println("\nIMPRIME 20 NUMEROS FIBONACCI\n");
penultimo = 0;
ultimo = 1;
for (i = 1; i <= 20; i++)
{
numero = penultimo + ultimo;
System.out.println(numero + " ");
penultimo = ultimo;
ultimo = numero;
}
}
}
-----------------------------------------------------------------------------------------------------------------------------------
import java.io.*;
public class ImprimeNumeros1
{
public static void main(String args[])
{
int i;
System.out.println("\nIMPRIME LOS NUMEROS DEL 1 AL 10\n");
for (i = 1; i <= 10; i++)
{
System.out.println(i);
}
}
}
-----------------------------------------------------------------------------------------------------------------------------------
import java.io.*;
public class Interes1
{
public static void main(String args[])
{
int mes;
float saldo, capital, interes, totInteres;
System.out.println("\n IMPRIME EL COMPORTAMIENTO DE UNA INVERSION\n");
System.out.println(" INVERSION");
System.out.println(" MES CAPITAL INTERES SALDO");
System.out.println("---------------------------------------------");
capital = 10000.00F;
totInteres = 0;
for (mes=1; mes<=24; mes++)
{
interes = capital * (0.36F/12F);
saldo = capital + interes;
System.out.println(mes + " " + capital + " " + interes + " " + saldo);
totInteres = totInteres + interes;
capital = saldo;
}
System.out.println("---------------------------------------------");
System.out.println(" " + totInteres);
}
}
-----------------------------------------------------------------------------------------------------------------------------------
import java.io.*;
public class Interes2
{
public static void main(String args[])
{
InputStreamReader entrada = new InputStreamReader(System.in);
BufferedReader flujoEntrada = new BufferedReader(entrada);
String datoEntrada;
int mes, plazo;
float saldo, capital, interes, totInteres, tasaAnual;
System.out.println("\n IMPRIME EL COMPORTAMIENTO DE UNA INVERSION\n");
try
{
System.out.print("Teclee el capital: ");
datoEntrada = flujoEntrada.readLine();
capital = Float.parseFloat(datoEntrada);
System.out.print("Teclee tasa interes anual: ");
datoEntrada = flujoEntrada.readLine();
tasaAnual = Float.parseFloat(datoEntrada);
System.out.print("Teclee plazo en meses: ");
datoEntrada = flujoEntrada.readLine();
plazo = Integer.parseInt(datoEntrada);
System.out.println(" INVERSION");
System.out.println("CAPITAL = " + capital);
System.out.println("TASA INTERES ANUAL = " + tasaAnual);
System.out.println("PLAZO EN MESES = " + plazo);
System.out.println(" MES CAPITAL INTERES SALDO");
System.out.println("---------------------------------------------");
totInteres = 0;
for (mes=1; mes<=plazo; mes++)
{
interes = capital * (tasaAnual/100/12F);
saldo = capital + interes;
System.out.println(mes + " " + capital + " " +
interes + " " + saldo);
totInteres = totInteres + interes;
capital = saldo;
}
System.out.println("---------------------------------------------");
System.out.println(" " + totInteres);
}
catch (IOException error)
{
System.err.println("Error " + error.getMessage());
}
}
}
------------------------------------------------------------------------------------------------------------------------------------
import java.io.*;
public class Logaritmos1
{
public static void main(String args[])
{
double x, senoX, cosenoX, arcoTanX;
System.out.println("\nCALCULA SENO COSENO ARCO TANGENTE DE -1 HASTA 1\n");
System.out.println(" X Seno X Coseno X Arco tangente X");
System.out.println("----------------------------------------------------");
for (x = -1; x <= 1; x=x+0.2)
{
senoX = Math.sin(x);
cosenoX = Math.cos(x);
arcoTanX = Math.atan(x);
System.out.println(x + " " + senoX + " " + cosenoX +" " + arcoTanX);
}
}
}
-------------------------------------------------------------------------------------------------------------------------------------
import java.io.*;
public class Obreros2
{
public static void main(String args[])
{
InputStreamReader entrada = new InputStreamReader(System.in);
BufferedReader flujoEntrada = new BufferedReader(entrada);
String datoEntrada;
String nombreObr="", obrMayor="", obrMenor="";
int proDia=0, totProd, toTotProd, totObreros, i, mayorProd, menorProd;
char otro=' ';
System.out.println("\n PROCESA LA PRODUCCION DE 15 OBREROS\n");
try
{
System.out.println(" REPORTE DE PRODUCCION");
System.out.println("NOMBRE DEL OBRERO TOTAL PRODUCCION");
System.out.println("--------------------------------------------");
totObreros = 0;
toTotProd = 0;
mayorProd = 0;
menorProd = 10000;
for (i=1; i<=15; i++)
{
System.out.println("\n------------ Entrada de datos ------------");
System.out.print("Teclee nombre: ");
datoEntrada = flujoEntrada.readLine();
nombreObr = datoEntrada;
totProd = 0;
do
{
System.out.print("Teclee produccion del dia: ");
datoEntrada = flujoEntrada.readLine();
proDia = Integer.parseInt(datoEntrada);
totProd = totProd + proDia;
System.out.print("\n¿Desea procesar otro Dia(S/N)?: ");
otro = (char)System.in.read();
System.in.skip(2);
} while (otro == 'S' || otro == 's');
System.out.println("\n----------------- Salida -----------------");
System.out.println("Nombre = " + nombreObr);
System.out.println("Total produccion = " + totProd);
if (totProd > mayorProd)
{
mayorProd = totProd;
obrMayor = nombreObr;
}
if (totProd < menorProd)
{
menorProd = totProd;
obrMenor = nombreObr;
}
totObreros = totObreros + 1;
toTotProd = toTotProd + totProd;
}
System.out.println("\n------------------ Total -----------------");
System.out.println("Total obreros = " + totObreros);
System.out.println("Total produccion = " + toTotProd);
System.out.println("Nombre Obrero mas Productivo = " + obrMayor);
System.out.println("Produccion que Fabrico= " + mayorProd);
System.out.println("Nombre Obrero menos Productivo = " + obrMenor);
System.out.println("Produccion que Fabrico= " + menorProd);
}
catch (IOException error)
{
System.err.println("Error " + error.getMessage());
}
}
}
-----------------------------------------------------------------------------------------------------------------------------------
import java.io.*;
public class Obreros3
{
public static void main(String args[])
{
InputStreamReader entrada = new InputStreamReader(System.in);
BufferedReader flujoEntrada = new BufferedReader(entrada);
String datoEntrada;
String nombreObr="", obrMayor="", obrMenor="";
int proDia=0, totProd, toTotProd, totObreros, i, mayorProd, menorProd;
char desea=' ';
System.out.println("\n PROCESA LA PRODUCCION DE VARIOS OBREROS\n");
try
{
System.out.println(" REPORTE DE PRODUCCION");
System.out.println("NOMBRE DEL OBRERO TOTAL PRODUCCION");
System.out.println("--------------------------------------------");
totObreros = 0;
toTotProd = 0;
mayorProd = 0;
menorProd = 10000;
do
{
System.out.println("\n------------ Entrada de datos ------------");
System.out.print("Teclee nombre: ");
datoEntrada = flujoEntrada.readLine();
nombreObr = datoEntrada;
totProd = 0;
for (i=1; i<=6; i++)
{
System.out.print("Teclee produccion del dia: ");
datoEntrada = flujoEntrada.readLine();
proDia = Integer.parseInt(datoEntrada);
totProd = totProd + proDia;
}
System.out.println("\n----------------- Salida -----------------");
System.out.println("Nombre = " + nombreObr);
System.out.println("Total produccion = " + totProd);
if (totProd > mayorProd)
{
mayorProd = totProd;
obrMayor = nombreObr;
}
if (totProd < menorProd)
{
menorProd = totProd;
obrMenor = nombreObr;
}
totObreros = totObreros + 1;
toTotProd = toTotProd + totProd;
System.out.print("\n¿Desea procesar otro obrero(S/N)?: ");
desea = (char)System.in.read();
System.in.skip(2);
} while (desea == 'S' || desea == 's');
System.out.println("\n------------------ Total -----------------");
System.out.println("Total obreros = " + totObreros);
System.out.println("Total produccion = " + toTotProd);
System.out.println("Nombre Obrero mas Productivo = " + obrMayor);
System.out.println("Produccion que Fabrico= " + mayorProd);
System.out.println("Nombre Obrero menos Productivo = " + obrMenor);
System.out.println("Produccion que Fabrico= " + menorProd);
}
catch (IOException error)
{
System.err.println("Error " + error.getMessage());
}
}
}
------------------------------------------------------------------------------------------------------------------------------------
import java.io.*;
public class PoblacionEstudiantil
{
public static void main(String args[])
{
int n;
float pobFinal;
System.out.println("\nESTIMA POBLACION ESTUDIANTIL\n");
pobFinal = 750;
for (n = 2004; n <= 2015; n++)
{
pobFinal = pobFinal + (pobFinal * 0.12F);
}
System.out.println("La poblacion estudiantil sera de " + pobFinal);
}
}
-----------------------------------------------------------------------------------------------------------------------------------
import java.io.*;
public class Potencias2
{
public static void main(String args[])
{
int i, numero, potencia;
System.out.println("\nIMPRIME POTENCIAS 1-8\n");
System.out.println("\nNUMERO POTENCIA");
System.out.println("\n------------------");
for (numero = 1; numero <= 8; numero++)
{
potencia = numero;
for (i = 1; i < numero; i++)
{
potencia = potencia * numero;
}
System.out.println(" " + numero + " " + potencia);
}
}
}
------------------------------------------------------------------------------------------------------------------------------------
import java.io.*;
public class PromedioNumeros1
{
public static void main(String args[])
{
InputStreamReader entrada = new InputStreamReader(System.in);
BufferedReader flujoEntrada = new BufferedReader(entrada);
String datoEntrada;
int i, numero, sumatoria;
float promedio;
System.out.println("\nCALCULA EL PROMEDIO DE 20 NUMEROS\n");
System.out.println("------------ Entrada de datos ------------");
try
{
sumatoria = 0;
for (i = 1; i <= 20; i++)
{
System.out.print("Teclee el numero " + i + " : ");
datoEntrada = flujoEntrada.readLine();
numero = Integer.parseInt(datoEntrada);
sumatoria = sumatoria + numero;
}
promedio = (float)sumatoria / (float)20;
System.out.println("\n----------------- Salida -----------------");
System.out.println("Promedio = " + promedio);
}
catch (IOException error)
{
System.err.println("Error " + error.getMessage());
}
}
}
------------------------------------------------------------------------------------------------------------------------------------
import java.io.*;
public class PromedioNumeros2
{
public static void main(String args[])
{
InputStreamReader entrada = new InputStreamReader(System.in);
BufferedReader flujoEntrada = new BufferedReader(entrada);
String datoEntrada;
int i, n, numero, sumatoria;
float promedio;
System.out.println("\nCALCULA EL PROMEDIO DE N NUMEROS\n");
System.out.println("------------ Entrada de datos ------------");
try
{
System.out.print("¿A cuantos numeros desea calcular el promedio : ");
datoEntrada = flujoEntrada.readLine();
n = Integer.parseInt(datoEntrada);
sumatoria = 0;
for (i = 1; i <= n; i++)
{
System.out.print("Teclee el numero " + i + " : ");
datoEntrada = flujoEntrada.readLine();
numero = Integer.parseInt(datoEntrada);
sumatoria = sumatoria + numero;
}
promedio = (float)sumatoria / (float)n;
System.out.println("\n----------------- Salida -----------------");
System.out.println("Promedio = " + promedio);
}
catch (IOException error)
{
System.err.println("Error " + error.getMessage());
}
}
}
------------------------------------------------------------------------------------------------------------------------------------
import java.io.*;
public class SumaNumeros1
{
public static void main(String args[])
{
int indice, sumatoria;
System.out.println("\nIMPRIME LA SUMATORIA DE LOS NUMEROS DEL 1 AL 100\n");
sumatoria = 0;
for (indice = 1; indice <= 100; indice++)
{
sumatoria = sumatoria + indice;
}
System.out.println("La sumatoria es = " + sumatoria);
}
}
----------------------------------------------------------------------------------------------------------------------------------
import java.io.*;
public class SumaNumeros2
{
public static void main(String args[])
{
int i, suma;
System.out.println("\nIMPRIME LA SUMATORIA DE LOS NUMEROS DEL 2 AL 160\n");
suma = 0;
for (i = 2; i <= 160; i++)
{
suma = suma + i;
}
System.out.println("La sumatoria es = " + suma);
}
}
-------------------------------------------------------------------------------------------------------------------------------------
import java.io.*;
public class SumaNumeros3
{
public static void main(String args[])
{
int i;
float valor, suma;
System.out.println("\nIMPRIME LA SUMATORIA DE 1 + 1/2 + .... + 1/50\n");
suma = 0;
for (i = 2; i <= 160; i++)
{
valor = 1 / (float)i;
suma = suma + valor;
}
System.out.println("La sumatoria es = " + suma);
}
}
------------------------------------------------------------------------------------------------------------------------------------
import java.io.*;
public class Trabajadores
{
public static void main(String args[])
{
InputStreamReader entrada = new InputStreamReader(System.in);
BufferedReader flujoEntrada = new BufferedReader(entrada);
String datoEntrada;
String nombreTra="";
int t, d, totTrab, proDia=0, totProd, totProdGral;
System.out.println("\n PROCESA LA PRODUCCION DE 15 TRABAJADORES\n");
try
{
System.out.println(" REPORTE SEMANAL DE PRODUCCION");
System.out.println("NOMBRE DEL TRABAJADOR UNIDADES PRODUCIDAS");
System.out.println("--------------------------------------------");
totTrab = 0;
totProdGral = 0;
for (t=1; t<=15; t++)
{
System.out.println("\n------------ Entrada de datos ------------");
System.out.print("Teclee nombre: ");
datoEntrada = flujoEntrada.readLine();
nombreTra = datoEntrada;
totProd = 0;
for (d=1; d<=6; d++)
{
System.out.print("Teclee produccion del dia: ");
datoEntrada = flujoEntrada.readLine();
proDia = Integer.parseInt(datoEntrada);
totProd = totProd + proDia;
}
System.out.println("\n----------------- Salida -----------------");
System.out.println("Nombre = " + nombreTra);
System.out.println("Unidades producidas = " + totProd);
totTrab = totTrab + 1;
totProdGral = totProdGral + totProd;
}
System.out.println("\n------------------ Total -----------------");
System.out.println("Total trabajadores = " + totTrab);
System.out.println("Total produccion general = " + totProdGral);
}
catch (IOException error)
{
System.err.println("Error " + error.getMessage());
}
}
}
import java.io.*;
public class Alumnos1
{
public static void main(String args[])
{
InputStreamReader entrada = new InputStreamReader(System.in);
BufferedReader flujoEntrada = new BufferedReader(entrada);
String datoEntrada;
String nombreAlum="";
int totAlumnos;
float calif1=0, calif2=0, calif3=0, calif4=0, promedio, promCal1, promCal2,
promCal3, promCal4, promProm, totCal1, totCal2, totCal3, totCal4,
totProm;
char desea=' ';
System.out.println("\n CALCULA CALIFICACIONES DE ALUMNOS\n");
try
{
System.out.println(" ANALISIS DE CALIFICACIONES");
System.out.print(" NOMBRE CAL.1 CAL.2");
System.out.println(" CAL.3 CAL.4 PROMEDIO");
System.out.print("-------------------------------------------");
System.out.println("------------------------");
totAlumnos = 0;
totCal1 = 0; totCal2 = 0; totCal3 = 0;
totCal4 = 0; totProm = 0;
do
{
System.out.println("-------------- Entrada de datos --------------");
System.out.print("Teclee nombre: ");
datoEntrada = flujoEntrada.readLine();
nombreAlum = datoEntrada;
System.out.print("Teclee calificacion 1: ");
datoEntrada = flujoEntrada.readLine();
calif1 = Float.parseFloat(datoEntrada);
System.out.print("Teclee calificacion 2: ");
datoEntrada = flujoEntrada.readLine();
calif2 = Float.parseFloat(datoEntrada);
System.out.print("Teclee calificacion 3: ");
datoEntrada = flujoEntrada.readLine();
calif3 = Float.parseFloat(datoEntrada);
System.out.print("Teclee calificacion 4: ");
datoEntrada = flujoEntrada.readLine();
calif4 = Float.parseFloat(datoEntrada);
promedio = (calif1 + calif2 + calif3 + calif4) / 4;
System.out.println("\n------------------- Salida -------------------");
System.out.println("Nombre = " + nombreAlum);
System.out.println("Calificacion 1 = " + calif1);
System.out.println("Calificacion 2 = " + calif2);
System.out.println("Calificacion 3 = " + calif3);
System.out.println("Calificacion 4 = " + calif4);
System.out.println("Promedio = " + promedio);
totAlumnos = totAlumnos + 1;
totCal1 = totCal1 + calif1;
totCal2 = totCal2 + calif2;
totCal3 = totCal3 + calif3;
totCal4 = totCal4 + calif4;
totProm = totProm + promedio;
System.out.print("\n¿Desea procesar otro alumno(S/N)?: ");
desea = (char)System.in.read();
System.in.skip(2);
} while (desea == 'S' || desea == 's');
promCal1 = totCal1 / totAlumnos;
promCal2 = totCal2 / totAlumnos;
promCal3 = totCal3 / totAlumnos;
promCal4 = totCal4 / totAlumnos;
promProm = totProm / totAlumnos;
System.out.println("\n------------- Promedios Generales ------------");
System.out.println("Promedio Calificacion 1 = " + promCal1);
System.out.println("Promedio Calificacion 2 = " + promCal2);
System.out.println("Promedio Calificacion 3 = " + promCal3);
System.out.println("Promedio Calificacion 4 = " + promCal4);
System.out.println("Promedio de promedios = " + promProm);
}
catch (IOException error)
{
System.err.println("Error " + error.getMessage());
}
}
}
------------------------------------------------------------------------------------------------------------------------------------
import java.io.*;
public class Alumnos2
{
public static void main(String args[])
{
InputStreamReader entrada = new InputStreamReader(System.in);
BufferedReader flujoEntrada = new BufferedReader(entrada);
String datoEntrada;
String nombreAlum="";
int totAprobados, totReprobados;
float calif1=0, calif2=0, calif3=0, calif4=0, caliFinal;
String observacion;
char desea=' ';
System.out.println("\n CALCULA CALIFICACIONES DE ALUMNOS\n");
try
{
System.out.println(" CALIFICACIONES FINALES");
System.out.print(" NOMBRE CAL.1 CAL.2");
System.out.println(" CAL.3 CALIF.FINAL OBSERVACION");
System.out.print("-------------------------------------------");
System.out.println("---------------------------------");
totAprobados = 0;
totReprobados = 0;
do
{
System.out.println("-------------- Entrada de datos --------------");
System.out.print("Teclee nombre: ");
datoEntrada = flujoEntrada.readLine();
nombreAlum = datoEntrada;
System.out.print("Teclee calificacion 1: ");
datoEntrada = flujoEntrada.readLine();
calif1 = Float.parseFloat(datoEntrada);
System.out.print("Teclee calificacion 2: ");
datoEntrada = flujoEntrada.readLine();
calif2 = Float.parseFloat(datoEntrada);
System.out.print("Teclee calificacion 3: ");
datoEntrada = flujoEntrada.readLine();
calif3 = Float.parseFloat(datoEntrada);
caliFinal = (calif1 * 0.2F) + (calif2 * 0.3F) + (calif3 *0.5F);
if (caliFinal >= 60)
{
totAprobados = totAprobados + 1;
observacion = "Aprobado";
}
else
{
totReprobados = totReprobados + 1;
observacion = "Reprobado";
}
System.out.println("\n------------------- Salida -------------------");
System.out.println("Nombre = " + nombreAlum);
System.out.println("Calificacion 1 = " + calif1);
System.out.println("Calificacion 2 = " + calif2);
System.out.println("Calificacion 3 = " + calif3);
System.out.println("Calificacion final = " + caliFinal);
System.out.println("Observacion = " + observacion);
System.out.print("\n¿Desea procesar otro alumno(S/N)?: ");
desea = (char)System.in.read();
System.in.skip(2);
} while (desea == 'S' || desea == 's');
System.out.println("\n------------------- Totales ------------------");
System.out.println("Total Aprobados = " + totAprobados);
System.out.println("Total Reprobados = " + totReprobados);
}
catch (IOException error)
{
System.err.println("Error " + error.getMessage());
}
}
}
--------------------------------------------------------------------------------------------------------------------------------------
import java.io.*;
public class ArticulosInfla
{
public static void main(String args[])
{
InputStreamReader entrada = new InputStreamReader(System.in);
BufferedReader flujoEntrada = new BufferedReader(entrada);
String datoEntrada;
String articulo="", articuloMayor="";
int totArticulos;
float precioAct=0, precioAnt=0, ptjeInfla, totInfla,
mayorInfla, promInfla;
char otro=' ';
System.out.println("\n PROCESA INFLACION DE VARIOS ARTICULOS\n");
try
{
System.out.println(" ANALISIS DE INFLACION");
System.out.println(" PRECIO PRECIO PORCENTAJE");
System.out.println(" ARTICULO ANTERIOR ACTUAL INFLACION");
System.out.println("-------------------------------------------------------------");
totArticulos = 0;
totInfla = 0;
mayorInfla = 0;
do
{
System.out.println("-------------- Entrada de datos --------------");
System.out.print("Teclee Articulo: ");
datoEntrada = flujoEntrada.readLine();
articulo = datoEntrada;
System.out.print("Teclee Precio Anterior: ");
datoEntrada = flujoEntrada.readLine();
precioAnt = Float.parseFloat(datoEntrada);
System.out.print("Teclee Precio Actual: ");
datoEntrada = flujoEntrada.readLine();
precioAct = Float.parseFloat(datoEntrada);
ptjeInfla = ((precioAct - precioAnt) / precioAnt) * 100;
System.out.println("\n------------------- Salida -------------------");
System.out.println("Articulo = " + articulo);
System.out.println("Precio Anterior = " + precioAnt);
System.out.println("Precio Actual = " + precioAct);
System.out.println("Porcentaje de Inflacion = " + ptjeInfla);
if (ptjeInfla > mayorInfla)
{
mayorInfla = ptjeInfla;
articuloMayor = articulo;
}
totArticulos = totArticulos + 1;
totInfla = totInfla + ptjeInfla;
System.out.print("\n¿Desea procesar otro articulo(S/N)?: ");
otro = (char)System.in.read();
System.in.skip(2);
} while (otro == 'S' || otro == 's');
promInfla = totInfla / totArticulos;
System.out.println("\n------------------- Totales ------------------");
System.out.println("Promedio de Inflacion = " + promInfla);
System.out.println("Articulo con Mayor Inflacion = " + articuloMayor);
System.out.println("Porcentaje Mayor de Inflacion = " + mayorInfla);
}
catch (IOException error)
{
System.err.println("Error " + error.getMessage());
}
}
}
------------------------------------------------------------------------------------------------------------------------------------
import java.io.*;
public class Clientes1
{
public static void main(String args[])
{
InputStreamReader entrada = new InputStreamReader(System.in);
BufferedReader flujoEntrada = new BufferedReader(entrada);
String datoEntrada;
String nombreClie="";
int tipoClie=0, cantidad=0, totClientes;
float precioUni=0, subTotal, descuento=0, netoPagar,
totSubTot,totDescuento, totNeto;
char desea=' ';
System.out.println("\n PROCESA VARIOS CLIENTES\n");
try
{
System.out.println(" REPORTE DE CLIENTES");
System.out.print(" NOMBRE SUB.TOTAL ");
System.out.println("DESCUENTO TOTAL A PAGAR");
System.out.print("---------------------------------------------");
System.out.println("----------------------------");
totClientes = 0;
totSubTot = 0;
totDescuento = 0;
totNeto = 0;
do
{
System.out.println("-------------- Entrada de datos --------------");
System.out.print("Teclee nombre: ");
datoEntrada = flujoEntrada.readLine();
nombreClie = datoEntrada;
System.out.print("Teclee tipo de cliente (1-4): ");
datoEntrada = flujoEntrada.readLine();
tipoClie = Integer.parseInt(datoEntrada);
System.out.print("Teclee cantidad de piezas compradas: ");
datoEntrada = flujoEntrada.readLine();
cantidad = Integer.parseInt(datoEntrada);
System.out.print("Teclee precio unitario: ");
datoEntrada = flujoEntrada.readLine();
precioUni = Float.parseFloat(datoEntrada);
subTotal = cantidad * precioUni;
switch (tipoClie)
{
case 1:
descuento = subTotal * 0.05F;
break;
case 2:
descuento = subTotal * 0.08F;
break;
case 3:
descuento = subTotal * 0.12F;
break;
case 4:
descuento = subTotal * 0.15F;
break;
}
netoPagar = subTotal - descuento;
System.out.println("\n------------------- Salida -------------------");
System.out.println("Nombre = " + nombreClie);
System.out.println("Subtotal = " + subTotal);
System.out.println("Descuento = " + descuento);
System.out.println("Neto a pagar = " + netoPagar);
totClientes = totClientes + 1;
totSubTot = totSubTot + subTotal;
totDescuento = totDescuento + descuento;
totNeto = totNeto + netoPagar;
System.out.print("\n¿Desea procesar otro cliente(S/N)?: ");
desea = (char)System.in.read();
System.in.skip(2);
} while (desea == 'S' || desea == 's');
System.out.println("\n------------------- Totales ------------------");
System.out.println("Total Clientes = " + totClientes);
System.out.println("Total Sub Total = " + totSubTot);
System.out.println("Total Descuento = " + totDescuento);
System.out.println("Total Neto a Pagar = " + totNeto);
}
catch (IOException error)
{
System.err.println("Error " + error.getMessage());
}
}
}
----------------------------------------------------------------------------------------------------------------------------------
import java.io.*;
public class Clientes2
{
public static void main(String args[])
{
InputStreamReader entrada = new InputStreamReader(System.in);
BufferedReader flujoEntrada = new BufferedReader(entrada);
String datoEntrada;
String nombreClie="", articulo="";
char otro=' ', hay=' ';
int totClientes, cantidad;
float precio, totPagar, totPagarClie, totPagarGral;
System.out.println("\n PROCESA LA VENTA A VARIOS CLIENTES\n");
try
{
System.out.println(" REPORTE DE VENTAS");
System.out.println("NOMBRE ARTICULO TOTAL PAGAR");
System.out.println("--------------------------------------------");
totClientes = 0;
totPagarGral = 0;
do
{
System.out.println("\n------------ Entrada de datos ------------");
System.out.print("Teclee nombre: ");
datoEntrada = flujoEntrada.readLine();
nombreClie = datoEntrada;
System.out.println("Nombre = " + nombreClie);
totPagarClie = 0;
do
{
System.out.print("Teclee articulo: ");
datoEntrada = flujoEntrada.readLine();
articulo = datoEntrada;
System.out.print("Teclee cantidad de articulos: ");
datoEntrada = flujoEntrada.readLine();
cantidad = Integer.parseInt(datoEntrada);
System.out.print("Teclee precio unitario: ");
datoEntrada = flujoEntrada.readLine();
precio = Float.parseFloat(datoEntrada);
totPagar = cantidad * precio;
System.out.println("Articulo = " + articulo);
System.out.println("Total a Pagar = " + totPagar);
totPagarClie = totPagarClie + totPagar;
System.out.print("\n¿Desea procesar otro articulo(S/N)?: ");
hay = (char)System.in.read();
System.in.skip(2);
} while (hay == 'S' || hay == 's');
System.out.println("Total pagar cliente = " + totPagarClie);
totClientes = totClientes + 1;
totPagarGral = totPagarGral + totPagarClie;
System.out.print("\n¿Desea procesar otro cliente(S/N)?: ");
otro = (char)System.in.read();
System.in.skip(2);
} while (otro == 'S' || otro == 's');
System.out.println("\n------------------ Total -----------------");
System.out.println("Total clientes = " + totClientes);
System.out.println("Total pagar general = " + totPagarGral);
}
catch (IOException error)
{
System.err.println("Error " + error.getMessage());
}
}
}
------------------------------------------------------------------------------------------------------------------------------------
import java.io.*;
public class Cuadratica3
{
public static void main(String args[])
{
double a=0, b=0, c=0, raizUnica, parteReal, parteImaginaria,
raizReal1, raizReal2;
System.out.println("\n REALIZA CALCULOS CON LA ECUACION CUADRATICA\n");
System.out.println(" A B C TIENE RAIZ 1 RAIZ 2");
System.out.println("---------------------------------------------");
a = 0;
do
{
a = a + 1;
c = c - a;
b = a - c;
System.out.print(a + " " + b + " " + c);
if ((Math.pow(b,2)-4*a*c) == 0)
{
raizUnica = -b/(2*a);
System.out.println(" Raiz unica " + raizUnica);
}
else
if ((Math.pow(b,2)-4*a*c) < 0)
{
parteReal = -b/(2*a);
parteImaginaria = Math.sqrt(Math.abs(Math.pow(b,2)-4*a*c))/(2*a);
System.out.print(" Raices complejas ");
System.out.println(" Parte real Parte imaginaria");
System.out.println(parteReal + " + " + parteImaginaria);
System.out.println(parteReal + " - " + parteImaginaria);
}
else
{
raizReal1 = -b + Math.sqrt(Math.pow(b,2)-4*a*c)/(2*a);
raizReal2 = -b - Math.sqrt(Math.pow(b,2)-4*a*c)/(2*a);
System.out.print(" Raices reales ");
System.out.println(raizReal1 + " " + raizReal2);
}
} while (a != 5);
}
}
--------------------------------------------------------------------------------------------------------------------------------------
import java.io.*;
public class Empleados1
{
public static void main(String args[])
{
InputStreamReader entrada = new InputStreamReader(System.in);
BufferedReader flujoEntrada = new BufferedReader(entrada);
String datoEntrada;
String nombreEmp="";
int horasTrab=0;
float cuotaHora=0;
float sueldo;
char desea=' ';
System.out.println("\n CALCULA EL SUELDO DE VARIOS EMPLEADOS");
try
{
do
{
System.out.println("\n------------ Entrada de datos ------------");
System.out.print("Teclee nombre: ");
datoEntrada = flujoEntrada.readLine();
nombreEmp = datoEntrada;
System.out.print("Teclee horas trabajadas: ");
datoEntrada = flujoEntrada.readLine();
horasTrab = Integer.parseInt(datoEntrada);
System.out.print("Teclee cuota por hora: ");
datoEntrada = flujoEntrada.readLine();
cuotaHora = Float.parseFloat(datoEntrada);
sueldo = horasTrab * cuotaHora;
System.out.println("\n----------------- Salida -----------------");
System.out.println("Nombre = " + nombreEmp);
System.out.println("Sueldo = " + sueldo);
System.out.print("\n¿Desea procesar otro empleado(S/N)?: ");
desea = (char)System.in.read();
System.in.skip(2);
} while (desea == 'S' || desea == 's');
}
catch (IOException error)
{
System.err.println("Error " + error.getMessage());
}
}
}
-----------------------------------------------------------------------------------------------------------------------------------
import java.io.*;
public class Empleados2
{
public static void main(String args[])
{
InputStreamReader entrada = new InputStreamReader(System.in);
BufferedReader flujoEntrada = new BufferedReader(entrada);
String datoEntrada;
String nombreEmp="";
int horasTrab=0, totEmpleados;
float cuotaHora=0;
float sueldo, totSueldos;
char desea=' ';
System.out.println("\n CALCULA EL SUELDO DE VARIOS EMPLEADOS");
try
{
System.out.println(" REPORTE DE EMPLEADOS");
System.out.println(" NOMBRE SUELDO");
System.out.println("------------------------------------------");
totEmpleados = 0;
totSueldos = 0;
do
{
System.out.println("\n------------ Entrada de datos ------------");
System.out.print("Teclee nombre: ");
datoEntrada = flujoEntrada.readLine();
nombreEmp = datoEntrada;
System.out.print("Teclee horas trabajadas: ");
datoEntrada = flujoEntrada.readLine();
horasTrab = Integer.parseInt(datoEntrada);
System.out.print("Teclee cuota por hora: ");
datoEntrada = flujoEntrada.readLine();
cuotaHora = Float.parseFloat(datoEntrada);
sueldo = horasTrab * cuotaHora;
System.out.println("\n----------------- Salida -----------------");
System.out.println("Nombre = " + nombreEmp);
System.out.println("Sueldo = " + sueldo);
totEmpleados = totEmpleados + 1;
totSueldos = totSueldos + sueldo;
System.out.print("\n¿Desea procesar otro empleado(S/N)?: ");
desea = (char)System.in.read();
System.in.skip(2);
} while (desea == 'S' || desea == 's');
System.out.println("\n------------------ Total -----------------");
System.out.println("Total empleados = " + totEmpleados);
System.out.println("Total sueldos = " + totSueldos);
}
catch (IOException error)
{
System.err.println("Error " + error.getMessage());
}
}
}
------------------------------------------------------------------------------------------------------------------------------------
import java.io.*;
public class EquivalenciasFahr2
{
public static void main(String args[])
{
float fahrenheit, celsius;
System.out.println("\nCALCULA EQUIVALENCIAS FAHRENHEIT CELSIUS\n");
System.out.println("Fahrenheit Celsius");
System.out.println("-------------------------------");
fahrenheit = 0;
do
{
fahrenheit = fahrenheit + 1;
celsius = (5F/9F) * (fahrenheit-32);
System.out.println(fahrenheit + " " + celsius);
} while (fahrenheit != 65);
}
}
-----------------------------------------------------------------------------------------------------------------------------------
import java.io.*;
public class ImprimeNumeros3
{
public static void main(String args[])
{
int i;
System.out.println("\nIMPRIME LOS NUMEROS DEL 1 AL 10\n");
i = 0;
do
{
i = i + 1;
System.out.println(i);
} while (i < 10);
}
}
------------------------------------------------------------------------------------------------------------------------------------
import java.io.*;
public class Logaritmos2
{
public static void main(String args[])
{
double x, senoX, cosenoX, arcoTanX;
System.out.println("\nCALCULA SENO COSENO ARCO TANGENTE DE -1 HASTA 1\n");
System.out.println(" X Seno X Coseno X Arco tangente X");
System.out.println("----------------------------------------------------");
x = -1.2;
do
{
x = x + 0.2;
senoX = Math.sin(x);
cosenoX = Math.cos(x);
arcoTanX = Math.atan(x);
System.out.println(x + " " + senoX + " " + cosenoX +" " + arcoTanX);
} while (x != 1);
}
}
----------------------------------------------------------------------------------------------------------------------------------
import java.io.*;
public class Obreros1
{
public static void main(String args[])
{
InputStreamReader entrada = new InputStreamReader(System.in);
BufferedReader flujoEntrada = new BufferedReader(entrada);
String datoEntrada;
String nombreObr="", obrMayor="", obrMenor="";
int proDia=0, totProd, toTotProd, totObreros, mayorProd, menorProd;
char otro=' ', desea=' ';
System.out.println("\n PROCESA LA PRODUCCION DE VARIOS OBREROS\n");
try
{
System.out.println(" REPORTE DE PRODUCCION");
System.out.println("NOMBRE DEL OBRERO TOTAL PRODUCCION");
System.out.println("--------------------------------------------");
totObreros = 0;
toTotProd = 0;
mayorProd = 0;
menorProd = 10000;
do
{
System.out.println("\n------------ Entrada de datos ------------");
System.out.print("Teclee nombre: ");
datoEntrada = flujoEntrada.readLine();
nombreObr = datoEntrada;
totProd = 0;
do
{
System.out.print("Teclee produccion del dia: ");
datoEntrada = flujoEntrada.readLine();
proDia = Integer.parseInt(datoEntrada);
totProd = totProd + proDia;
System.out.print("\n¿Desea procesar otro Dia(S/N)?: ");
otro = (char)System.in.read();
System.in.skip(2);
} while (otro == 'S' || otro == 's');
System.out.println("\n----------------- Salida -----------------");
System.out.println("Nombre = " + nombreObr);
System.out.println("Unidades producidas = " + totProd);
if (totProd > mayorProd)
{
mayorProd = totProd;
obrMayor = nombreObr;
}
if (totProd < menorProd)
{
menorProd = totProd;
obrMenor = nombreObr;
}
totObreros = totObreros + 1;
toTotProd = toTotProd + totProd;
System.out.print("\n¿Desea procesar otro obrero(S/N)?: ");
desea = (char)System.in.read();
System.in.skip(2);
} while (desea == 'S' || desea == 's');
System.out.println("\n------------------ Total -----------------");
System.out.println("Total obreros = " + totObreros);
System.out.println("Total produccion = " + toTotProd);
System.out.println("Nombre Obrero mas Productivo = " + obrMayor);
System.out.println("Produccion que Fabrico= " + mayorProd);
System.out.println("Nombre Obrero menos Productivo = " + obrMenor);
System.out.println("Produccion que Fabrico= " + menorProd);
}
catch (IOException error)
{
System.err.println("Error " + error.getMessage());
}
}
}
-----------------------------------------------------------------------------------------------------------------------------------
import java.io.*;
public class ValoresXYZ2
{
public static void main(String args[])
{
double x, y, z;
System.out.println("\nIMPRIME VALORES DE X Y Z\n");
System.out.println(" VALORES DE X Y Z");
System.out.println(" X Y Z");
System.out.println("----------------------");
x = 0;
do
{
x = x + 0.5;
y = 3 * Math.pow(x,2) + 7 * x - 15;
z = y - 2 * Math.pow(x,2);
System.out.println(x + " " + y + " " + z);
} while (x < 10);
}
}
-----------------------------------------------------------------------------------------------------------------------------------
import java.io.*;
public class Vendedores1
{
public static void main(String args[])
{
InputStreamReader entrada = new InputStreamReader(System.in);
BufferedReader flujoEntrada = new BufferedReader(entrada);
String datoEntrada;
String nombreVend="", articulo="";
char otro=' ', hay=' ';
int totVend, cantidad, clave;
float precio, totVendido, incentivo=0, totIncentivo,
venta, totGralIncentivo, totGralVenta;
System.out.println("\n PROCESA LA VENTA DE VARIOS VENDEDORES\n");
try
{
System.out.println(" REPORTE DE INCENTIVOS");
System.out.println("NOMBRE ARTICULO TOTAL PAGAR");
System.out.println("--------------------------------------------");
totVend = 0;
totGralVenta = 0;
totGralIncentivo = 0;
do
{
System.out.println("\n------------ Entrada de datos ------------");
System.out.print("Teclee nombre: ");
datoEntrada = flujoEntrada.readLine();
nombreVend = datoEntrada;
totVendido = 0;
totIncentivo = 0;
do
{
System.out.print("Teclee articulo: ");
datoEntrada = flujoEntrada.readLine();
articulo = datoEntrada;
System.out.print("Teclee clave de venta (1,2,3,4): ");
datoEntrada = flujoEntrada.readLine();
clave = Integer.parseInt(datoEntrada);
System.out.print("Teclee cantidad de articulos: ");
datoEntrada = flujoEntrada.readLine();
cantidad = Integer.parseInt(datoEntrada);
System.out.print("Teclee precio unitario: ");
datoEntrada = flujoEntrada.readLine();
precio = Float.parseFloat(datoEntrada);
venta = cantidad * precio;
switch (clave)
{
case 1:
incentivo = venta * 0.15F;
break;
case 2:
incentivo = venta * 0.1F;
break;
case 3:
incentivo = venta * 0.05F;
break;
case 4:
incentivo = venta * 0.03F;
break;
}
totVendido = totVendido + venta;
totIncentivo = totIncentivo + incentivo;
System.out.print("\n¿Desea procesar otro articulo(S/N)?: ");
hay = (char)System.in.read();
System.in.skip(2);
} while (hay == 'S' || hay == 's');
System.out.println("Nombre = " + nombreVend);
System.out.println("Total vendido = " + totVendido);
System.out.println("Total incentivo = " + totIncentivo);
totVend = totVend + 1;
totGralVenta = totGralVenta + totVendido;
totGralIncentivo = totGralIncentivo + totIncentivo;
System.out.print("\n¿Desea procesar otro vendedor(S/N)?: ");
otro = (char)System.in.read();
System.in.skip(2);
} while (otro == 'S' || otro == 's');
System.out.println("\n------------------ Total -----------------");
System.out.println("Total vendedores = " + totVend);
System.out.println("Total general venta = " + totGralVenta);
System.out.println("Total general incentivo = " + totGralIncentivo);
}
catch (IOException error)
{
System.err.println("Error " + error.getMessage());
}
}
}
-------------------------------------------------------------------------------------------------------------------------------------
import java.io.*;
public class Vendedores2
{
public static void main(String args[])
{
InputStreamReader entrada = new InputStreamReader(System.in);
BufferedReader flujoEntrada = new BufferedReader(entrada);
String datoEntrada;
String nombreVend="", articulo="";
char hay=' ';
int totVend, cantidad, clave;
float precio, totVendido, incentivo=0, totIncentivo,
venta, totGralIncentivo, totGralVenta;
System.out.println("\n PROCESA LA VENTA DE 15 VENDEDORES\n");
try
{
System.out.println(" REPORTE DE INCENTIVOS");
System.out.println("NOMBRE ARTICULO TOTAL PAGAR");
System.out.println("--------------------------------------------");
totVend = 0;
totGralVenta = 0;
totGralIncentivo = 0;
do
{
System.out.println("\n------------ Entrada de datos ------------");
System.out.print("Teclee nombre: ");
datoEntrada = flujoEntrada.readLine();
nombreVend = datoEntrada;
totVendido = 0;
totIncentivo = 0;
do
{
System.out.print("Teclee articulo: ");
datoEntrada = flujoEntrada.readLine();
articulo = datoEntrada;
System.out.print("Teclee clave de venta (1,2,3,4): ");
datoEntrada = flujoEntrada.readLine();
clave = Integer.parseInt(datoEntrada);
System.out.print("Teclee cantidad de articulos: ");
datoEntrada = flujoEntrada.readLine();
cantidad = Integer.parseInt(datoEntrada);
System.out.print("Teclee precio unitario: ");
datoEntrada = flujoEntrada.readLine();
precio = Float.parseFloat(datoEntrada);
venta = cantidad * precio;
switch (clave)
{
case 1:
incentivo = venta * 0.15F;
break;
case 2:
incentivo = venta * 0.1F;
break;
case 3:
incentivo = venta * 0.05F;
break;
case 4:
incentivo = venta * 0.03F;
break;
}
totVendido = totVendido + venta;
totIncentivo = totIncentivo + incentivo;
System.out.print("\n¿Desea procesar otro articulo(S/N)?: ");
hay = (char)System.in.read();
System.in.skip(2);
} while (hay == 'S' || hay == 's');
System.out.println("Nombre = " + nombreVend);
System.out.println("Total vendido = " + totVendido);
System.out.println("Total incentivo = " + totIncentivo);
totVend = totVend + 1;
totGralVenta = totGralVenta + totVendido;
totGralIncentivo = totGralIncentivo + totIncentivo;
} while (totVend != 15);
System.out.println("\n------------------ Total -----------------");
System.out.println("Total vendedores = " + totVend);
System.out.println("Total general venta = " + totGralVenta);
System.out.println("Total general incentivo = " + totGralIncentivo);
}
catch (IOException error)
{
System.err.println("Error " + error.getMessage());
}
}
}
------------------------------------------------------------------------------------------------------------------------------------
import java.io.*;
public class Vendedores3
{
public static void main(String args[])
{
InputStreamReader entrada = new InputStreamReader(System.in);
BufferedReader flujoEntrada = new BufferedReader(entrada);
String datoEntrada;
String nombreVend="";
char otro=' ';
int totVend, dia, mejorDia=0;
float ventaDia, totVenta, totVentaGral, mayorVenta;
System.out.println("\n PROCESA LA VENTA DE VARIOS VENDEDORES\n");
try
{
System.out.println(" REPORTE SEMANAL DE VENTAS");
System.out.println("NOMBRE VENTA SEMANAL DIA MAYOR VENTA");
System.out.println("-----------------------------------------------");
totVend = 0;
totVentaGral = 0;
do
{
System.out.println("\n------------ Entrada de datos ------------");
System.out.print("Teclee nombre: ");
datoEntrada = flujoEntrada.readLine();
nombreVend = datoEntrada;
totVenta = 0;
mayorVenta = 0;
for (dia=1; dia<=6; dia++)
{
System.out.print("Teclee venta del dia: ");
datoEntrada = flujoEntrada.readLine();
ventaDia = Float.parseFloat(datoEntrada);
totVenta = totVenta + ventaDia;
if (ventaDia > mayorVenta)
{
mayorVenta = ventaDia;
mejorDia = dia;
}
}
System.out.println("\n----------------- Salida -----------------");
System.out.println("Nombre = " + nombreVend);
System.out.println("Total venta = " + totVenta);
System.out.println("Mejor dia = " + mejorDia);
totVend = totVend + 1;
totVentaGral = totVentaGral + totVenta;
System.out.print("\n¿Hay otro vendedor(S/N)?: ");
otro = (char)System.in.read();
System.in.skip(2);
} while (otro == 'S' || otro == 's');
System.out.println("\n------------------ Total -----------------");
System.out.println("Total vendedores = " + totVend);
System.out.println("Total general venta = " + totVentaGral);
}
catch (IOException error)
{
System.err.println("Error " + error.getMessage());
}
}
}
----------------------------------------------------------------------------------------------------------------------------------
import java.io.*;
public class VendedoresAutos
{
public static void main(String args[])
{
InputStreamReader entrada = new InputStreamReader(System.in);
BufferedReader flujoEntrada = new BufferedReader(entrada);
String datoEntrada;
String nombreVend="";
char otro=' ', desea=' ';
int totAutos, totVend;
float precioAuto, salMin, sueldo, totSueldos, totVendido;
System.out.println("\nPROCESA LAS VENTAS DE VENDEDORES DE AUTOS\n");
try
{
System.out.print("Teclee salario minimo quincenal: ");
datoEntrada = flujoEntrada.readLine();
salMin = Float.parseFloat(datoEntrada);
System.out.println("\n NOMINA QUINCENAL");
System.out.println(" NOMBRE SUELDO");
System.out.println("------------------------------------------");
totSueldos = 0;
totVend = 0;
do
{
System.out.println("\n------------ Entrada de datos ------------");
System.out.print("Teclee nombre: ");
datoEntrada = flujoEntrada.readLine();
nombreVend = datoEntrada;
totAutos = 0;
totVendido = 0;
System.out.print("\n¿Hay auto vendido(S/N)?: ");
otro = (char)System.in.read();
System.in.skip(2);
while (otro == 'S' || otro == 's')
{
System.out.print("Teclee precio del auto: ");
datoEntrada = flujoEntrada.readLine();
precioAuto = Float.parseFloat(datoEntrada);
totAutos = totAutos + 1;
totVendido = totVendido + precioAuto;
System.out.print("\n¿Hay otro auto vendido(S/N)?: ");
otro = (char)System.in.read();
System.in.skip(2);
}
sueldo = salMin + (totAutos*100.00F) + (totVendido*0.02F);
System.out.println("\n----------------- Salida -----------------");
System.out.println("Nombre = " + nombreVend);
System.out.println("Sueldo = " + sueldo);
totVend = totVend + 1;
totSueldos = totSueldos + sueldo;
System.out.print("\n¿Desea procesar otro vendedor(S/N)?: ");
desea = (char)System.in.read();
System.in.skip(2);
} while (desea == 'S' || desea == 's');
System.out.println("\n------------------ Total -----------------");
System.out.println("Total vendedores = " + totVend);
System.out.println("Total sueldos = " + totSueldos);
}
catch (IOException error)
{
System.err.println("Error " + error.getMessage());
}
}
}
public class Cuadratica2
{
public static void main(String args[])
{
double a=0, b=0, c=0, raizUnica, parteReal, parteImaginaria,
raizReal1, raizReal2;
System.out.println("\n REALIZA CALCULOS CON LA ECUACION CUADRATICA\n");
System.out.println(" A B C TIENE RAIZ 1 RAIZ 2");
System.out.println("---------------------------------------------");
for (a=1; a<=5; a++)
{
c = c - a;
b = a - c;
System.out.print(a + " " + b + " " + c);
if ((Math.pow(b,2)-4*a*c) == 0)
{
raizUnica = -b/(2*a);
System.out.println(" Raiz unica " + raizUnica);
}
else
if ((Math.pow(b,2)-4*a*c) < 0)
{
parteReal = -b/(2*a);
parteImaginaria = Math.sqrt(Math.abs(Math.pow(b,2)-4*a*c))/(2*a);
System.out.print(" Raices complejas ");
System.out.println(" Parte real Parte imaginaria");
System.out.println(parteReal + " + " + parteImaginaria);
System.out.println(parteReal + " - " + parteImaginaria);
}
else
{
raizReal1 = -b + Math.sqrt(Math.pow(b,2)-4*a*c)/(2*a);
raizReal2 = -b - Math.sqrt(Math.pow(b,2)-4*a*c)/(2*a);
System.out.print(" Raices reales ");
System.out.println(raizReal1 + " " + raizReal2);
}
}
}
}
--------------------------------------------------------------------------------------------------------------------------------------
import java.io.*;
public class EquivalenciasFahr1
{
public static void main(String args[])
{
float fahrenheit, celsius;
System.out.println("\nCALCULA EQUIVALENCIAS FAHRENHEIT CELSIUS\n");
System.out.println("Fahrenheit Celsius");
System.out.println("-------------------------------");
for (fahrenheit = 1; fahrenheit <= 65; fahrenheit++)
{
celsius = (5F/9F) * (fahrenheit-32);
System.out.println(fahrenheit + " " + celsius);
}
}
}
----------------------------------------------------------------------------------------------------------------------------------
import java.io.*;
public class Factorial1
{
public static void main(String args[])
{
InputStreamReader entrada = new InputStreamReader(System.in);
BufferedReader flujoEntrada = new BufferedReader(entrada);
String datoEntrada;
int num, i, fact;
System.out.println("\nCALCULA EL FACTORIAL DE UN NUMERO\n");
try
{
System.out.println("-------- Entrada del dato --------");
System.out.print("Teclee numero: ");
datoEntrada = flujoEntrada.readLine();
num = Integer.parseInt(datoEntrada);
if (num == 0)
fact = 1;
else
{
fact = 1;
for (i = num; i >= 1; i--)
{
fact = fact * i;
}
}
System.out.println("\n------------- Salida -------------");
System.out.println("Factorial = " + fact);
}
catch (IOException error)
{
System.err.println("Error " + error.getMessage());
}
}
}
-----------------------------------------------------------------------------------------------------------------------------------
import java.io.*;
public class Factoriales1
{
public static void main(String args[])
{
InputStreamReader entrada = new InputStreamReader(System.in);
BufferedReader flujoEntrada = new BufferedReader(entrada);
String datoEntrada;
int n, i, j, fact, num;
System.out.println("\n CALCULA EL FACTORIAL DE N NUMEROS\n");
try
{
System.out.print("¿A cuantos numeros desea calcular factorial?: ");
datoEntrada = flujoEntrada.readLine();
n = Integer.parseInt(datoEntrada);
for (j = 1; j <= n; j++)
{
System.out.println("\n-------- Entrada del dato --------");
System.out.print("Teclee numero: ");
datoEntrada = flujoEntrada.readLine();
num = Integer.parseInt(datoEntrada);
if (num == 0)
fact = 1;
else
{
fact = 1;
for (i = num; i >= 1; i--)
{
fact = fact * i;
}
}
System.out.println("\n------------- Salida -------------");
System.out.println("Factorial = " + fact);
}
}
catch (IOException error)
{
System.err.println("Error " + error.getMessage());
}
}
}
-------------------------------------------------------------------------------------------------------------------------------------
import java.io.*;
public class Factoriales2
{
public static void main(String args[])
{
InputStreamReader entrada = new InputStreamReader(System.in);
BufferedReader flujoEntrada = new BufferedReader(entrada);
String datoEntrada;
int n, i, j, fact, num;
System.out.println("\n CALCULA EL FACTORIAL DE N NUMEROS\n");
try
{
System.out.print("¿A cuantos numeros desea calcular factorial?: ");
datoEntrada = flujoEntrada.readLine();
n = Integer.parseInt(datoEntrada);
j = 0;
do
{
j = j + 1;
System.out.println("\n-------- Entrada del dato --------");
System.out.print("Teclee numero: ");
datoEntrada = flujoEntrada.readLine();
num = Integer.parseInt(datoEntrada);
if (num == 0)
fact = 1;
else
{
fact = 1;
for (i = num; i >= 1; i--)
{
fact = fact * i;
}
}
System.out.println("\n------------- Salida -------------");
System.out.println("Factorial = " + fact);
} while (j != n);
}
catch (IOException error)
{
System.err.println("Error " + error.getMessage());
}
}
}
------------------------------------------------------------------------------------------------------------------------------------
import java.io.*;
public class Fibonacci
{
public static void main(String args[])
{
int i, numero, penultimo, ultimo;
System.out.println("\nIMPRIME 20 NUMEROS FIBONACCI\n");
penultimo = 0;
ultimo = 1;
for (i = 1; i <= 20; i++)
{
numero = penultimo + ultimo;
System.out.println(numero + " ");
penultimo = ultimo;
ultimo = numero;
}
}
}
-----------------------------------------------------------------------------------------------------------------------------------
import java.io.*;
public class ImprimeNumeros1
{
public static void main(String args[])
{
int i;
System.out.println("\nIMPRIME LOS NUMEROS DEL 1 AL 10\n");
for (i = 1; i <= 10; i++)
{
System.out.println(i);
}
}
}
-----------------------------------------------------------------------------------------------------------------------------------
import java.io.*;
public class Interes1
{
public static void main(String args[])
{
int mes;
float saldo, capital, interes, totInteres;
System.out.println("\n IMPRIME EL COMPORTAMIENTO DE UNA INVERSION\n");
System.out.println(" INVERSION");
System.out.println(" MES CAPITAL INTERES SALDO");
System.out.println("---------------------------------------------");
capital = 10000.00F;
totInteres = 0;
for (mes=1; mes<=24; mes++)
{
interes = capital * (0.36F/12F);
saldo = capital + interes;
System.out.println(mes + " " + capital + " " + interes + " " + saldo);
totInteres = totInteres + interes;
capital = saldo;
}
System.out.println("---------------------------------------------");
System.out.println(" " + totInteres);
}
}
-----------------------------------------------------------------------------------------------------------------------------------
import java.io.*;
public class Interes2
{
public static void main(String args[])
{
InputStreamReader entrada = new InputStreamReader(System.in);
BufferedReader flujoEntrada = new BufferedReader(entrada);
String datoEntrada;
int mes, plazo;
float saldo, capital, interes, totInteres, tasaAnual;
System.out.println("\n IMPRIME EL COMPORTAMIENTO DE UNA INVERSION\n");
try
{
System.out.print("Teclee el capital: ");
datoEntrada = flujoEntrada.readLine();
capital = Float.parseFloat(datoEntrada);
System.out.print("Teclee tasa interes anual: ");
datoEntrada = flujoEntrada.readLine();
tasaAnual = Float.parseFloat(datoEntrada);
System.out.print("Teclee plazo en meses: ");
datoEntrada = flujoEntrada.readLine();
plazo = Integer.parseInt(datoEntrada);
System.out.println(" INVERSION");
System.out.println("CAPITAL = " + capital);
System.out.println("TASA INTERES ANUAL = " + tasaAnual);
System.out.println("PLAZO EN MESES = " + plazo);
System.out.println(" MES CAPITAL INTERES SALDO");
System.out.println("---------------------------------------------");
totInteres = 0;
for (mes=1; mes<=plazo; mes++)
{
interes = capital * (tasaAnual/100/12F);
saldo = capital + interes;
System.out.println(mes + " " + capital + " " +
interes + " " + saldo);
totInteres = totInteres + interes;
capital = saldo;
}
System.out.println("---------------------------------------------");
System.out.println(" " + totInteres);
}
catch (IOException error)
{
System.err.println("Error " + error.getMessage());
}
}
}
------------------------------------------------------------------------------------------------------------------------------------
import java.io.*;
public class Logaritmos1
{
public static void main(String args[])
{
double x, senoX, cosenoX, arcoTanX;
System.out.println("\nCALCULA SENO COSENO ARCO TANGENTE DE -1 HASTA 1\n");
System.out.println(" X Seno X Coseno X Arco tangente X");
System.out.println("----------------------------------------------------");
for (x = -1; x <= 1; x=x+0.2)
{
senoX = Math.sin(x);
cosenoX = Math.cos(x);
arcoTanX = Math.atan(x);
System.out.println(x + " " + senoX + " " + cosenoX +" " + arcoTanX);
}
}
}
-------------------------------------------------------------------------------------------------------------------------------------
import java.io.*;
public class Obreros2
{
public static void main(String args[])
{
InputStreamReader entrada = new InputStreamReader(System.in);
BufferedReader flujoEntrada = new BufferedReader(entrada);
String datoEntrada;
String nombreObr="", obrMayor="", obrMenor="";
int proDia=0, totProd, toTotProd, totObreros, i, mayorProd, menorProd;
char otro=' ';
System.out.println("\n PROCESA LA PRODUCCION DE 15 OBREROS\n");
try
{
System.out.println(" REPORTE DE PRODUCCION");
System.out.println("NOMBRE DEL OBRERO TOTAL PRODUCCION");
System.out.println("--------------------------------------------");
totObreros = 0;
toTotProd = 0;
mayorProd = 0;
menorProd = 10000;
for (i=1; i<=15; i++)
{
System.out.println("\n------------ Entrada de datos ------------");
System.out.print("Teclee nombre: ");
datoEntrada = flujoEntrada.readLine();
nombreObr = datoEntrada;
totProd = 0;
do
{
System.out.print("Teclee produccion del dia: ");
datoEntrada = flujoEntrada.readLine();
proDia = Integer.parseInt(datoEntrada);
totProd = totProd + proDia;
System.out.print("\n¿Desea procesar otro Dia(S/N)?: ");
otro = (char)System.in.read();
System.in.skip(2);
} while (otro == 'S' || otro == 's');
System.out.println("\n----------------- Salida -----------------");
System.out.println("Nombre = " + nombreObr);
System.out.println("Total produccion = " + totProd);
if (totProd > mayorProd)
{
mayorProd = totProd;
obrMayor = nombreObr;
}
if (totProd < menorProd)
{
menorProd = totProd;
obrMenor = nombreObr;
}
totObreros = totObreros + 1;
toTotProd = toTotProd + totProd;
}
System.out.println("\n------------------ Total -----------------");
System.out.println("Total obreros = " + totObreros);
System.out.println("Total produccion = " + toTotProd);
System.out.println("Nombre Obrero mas Productivo = " + obrMayor);
System.out.println("Produccion que Fabrico= " + mayorProd);
System.out.println("Nombre Obrero menos Productivo = " + obrMenor);
System.out.println("Produccion que Fabrico= " + menorProd);
}
catch (IOException error)
{
System.err.println("Error " + error.getMessage());
}
}
}
-----------------------------------------------------------------------------------------------------------------------------------
import java.io.*;
public class Obreros3
{
public static void main(String args[])
{
InputStreamReader entrada = new InputStreamReader(System.in);
BufferedReader flujoEntrada = new BufferedReader(entrada);
String datoEntrada;
String nombreObr="", obrMayor="", obrMenor="";
int proDia=0, totProd, toTotProd, totObreros, i, mayorProd, menorProd;
char desea=' ';
System.out.println("\n PROCESA LA PRODUCCION DE VARIOS OBREROS\n");
try
{
System.out.println(" REPORTE DE PRODUCCION");
System.out.println("NOMBRE DEL OBRERO TOTAL PRODUCCION");
System.out.println("--------------------------------------------");
totObreros = 0;
toTotProd = 0;
mayorProd = 0;
menorProd = 10000;
do
{
System.out.println("\n------------ Entrada de datos ------------");
System.out.print("Teclee nombre: ");
datoEntrada = flujoEntrada.readLine();
nombreObr = datoEntrada;
totProd = 0;
for (i=1; i<=6; i++)
{
System.out.print("Teclee produccion del dia: ");
datoEntrada = flujoEntrada.readLine();
proDia = Integer.parseInt(datoEntrada);
totProd = totProd + proDia;
}
System.out.println("\n----------------- Salida -----------------");
System.out.println("Nombre = " + nombreObr);
System.out.println("Total produccion = " + totProd);
if (totProd > mayorProd)
{
mayorProd = totProd;
obrMayor = nombreObr;
}
if (totProd < menorProd)
{
menorProd = totProd;
obrMenor = nombreObr;
}
totObreros = totObreros + 1;
toTotProd = toTotProd + totProd;
System.out.print("\n¿Desea procesar otro obrero(S/N)?: ");
desea = (char)System.in.read();
System.in.skip(2);
} while (desea == 'S' || desea == 's');
System.out.println("\n------------------ Total -----------------");
System.out.println("Total obreros = " + totObreros);
System.out.println("Total produccion = " + toTotProd);
System.out.println("Nombre Obrero mas Productivo = " + obrMayor);
System.out.println("Produccion que Fabrico= " + mayorProd);
System.out.println("Nombre Obrero menos Productivo = " + obrMenor);
System.out.println("Produccion que Fabrico= " + menorProd);
}
catch (IOException error)
{
System.err.println("Error " + error.getMessage());
}
}
}
------------------------------------------------------------------------------------------------------------------------------------
import java.io.*;
public class PoblacionEstudiantil
{
public static void main(String args[])
{
int n;
float pobFinal;
System.out.println("\nESTIMA POBLACION ESTUDIANTIL\n");
pobFinal = 750;
for (n = 2004; n <= 2015; n++)
{
pobFinal = pobFinal + (pobFinal * 0.12F);
}
System.out.println("La poblacion estudiantil sera de " + pobFinal);
}
}
-----------------------------------------------------------------------------------------------------------------------------------
import java.io.*;
public class Potencias2
{
public static void main(String args[])
{
int i, numero, potencia;
System.out.println("\nIMPRIME POTENCIAS 1-8\n");
System.out.println("\nNUMERO POTENCIA");
System.out.println("\n------------------");
for (numero = 1; numero <= 8; numero++)
{
potencia = numero;
for (i = 1; i < numero; i++)
{
potencia = potencia * numero;
}
System.out.println(" " + numero + " " + potencia);
}
}
}
------------------------------------------------------------------------------------------------------------------------------------
import java.io.*;
public class PromedioNumeros1
{
public static void main(String args[])
{
InputStreamReader entrada = new InputStreamReader(System.in);
BufferedReader flujoEntrada = new BufferedReader(entrada);
String datoEntrada;
int i, numero, sumatoria;
float promedio;
System.out.println("\nCALCULA EL PROMEDIO DE 20 NUMEROS\n");
System.out.println("------------ Entrada de datos ------------");
try
{
sumatoria = 0;
for (i = 1; i <= 20; i++)
{
System.out.print("Teclee el numero " + i + " : ");
datoEntrada = flujoEntrada.readLine();
numero = Integer.parseInt(datoEntrada);
sumatoria = sumatoria + numero;
}
promedio = (float)sumatoria / (float)20;
System.out.println("\n----------------- Salida -----------------");
System.out.println("Promedio = " + promedio);
}
catch (IOException error)
{
System.err.println("Error " + error.getMessage());
}
}
}
------------------------------------------------------------------------------------------------------------------------------------
import java.io.*;
public class PromedioNumeros2
{
public static void main(String args[])
{
InputStreamReader entrada = new InputStreamReader(System.in);
BufferedReader flujoEntrada = new BufferedReader(entrada);
String datoEntrada;
int i, n, numero, sumatoria;
float promedio;
System.out.println("\nCALCULA EL PROMEDIO DE N NUMEROS\n");
System.out.println("------------ Entrada de datos ------------");
try
{
System.out.print("¿A cuantos numeros desea calcular el promedio : ");
datoEntrada = flujoEntrada.readLine();
n = Integer.parseInt(datoEntrada);
sumatoria = 0;
for (i = 1; i <= n; i++)
{
System.out.print("Teclee el numero " + i + " : ");
datoEntrada = flujoEntrada.readLine();
numero = Integer.parseInt(datoEntrada);
sumatoria = sumatoria + numero;
}
promedio = (float)sumatoria / (float)n;
System.out.println("\n----------------- Salida -----------------");
System.out.println("Promedio = " + promedio);
}
catch (IOException error)
{
System.err.println("Error " + error.getMessage());
}
}
}
------------------------------------------------------------------------------------------------------------------------------------
import java.io.*;
public class SumaNumeros1
{
public static void main(String args[])
{
int indice, sumatoria;
System.out.println("\nIMPRIME LA SUMATORIA DE LOS NUMEROS DEL 1 AL 100\n");
sumatoria = 0;
for (indice = 1; indice <= 100; indice++)
{
sumatoria = sumatoria + indice;
}
System.out.println("La sumatoria es = " + sumatoria);
}
}
----------------------------------------------------------------------------------------------------------------------------------
import java.io.*;
public class SumaNumeros2
{
public static void main(String args[])
{
int i, suma;
System.out.println("\nIMPRIME LA SUMATORIA DE LOS NUMEROS DEL 2 AL 160\n");
suma = 0;
for (i = 2; i <= 160; i++)
{
suma = suma + i;
}
System.out.println("La sumatoria es = " + suma);
}
}
-------------------------------------------------------------------------------------------------------------------------------------
import java.io.*;
public class SumaNumeros3
{
public static void main(String args[])
{
int i;
float valor, suma;
System.out.println("\nIMPRIME LA SUMATORIA DE 1 + 1/2 + .... + 1/50\n");
suma = 0;
for (i = 2; i <= 160; i++)
{
valor = 1 / (float)i;
suma = suma + valor;
}
System.out.println("La sumatoria es = " + suma);
}
}
------------------------------------------------------------------------------------------------------------------------------------
import java.io.*;
public class Trabajadores
{
public static void main(String args[])
{
InputStreamReader entrada = new InputStreamReader(System.in);
BufferedReader flujoEntrada = new BufferedReader(entrada);
String datoEntrada;
String nombreTra="";
int t, d, totTrab, proDia=0, totProd, totProdGral;
System.out.println("\n PROCESA LA PRODUCCION DE 15 TRABAJADORES\n");
try
{
System.out.println(" REPORTE SEMANAL DE PRODUCCION");
System.out.println("NOMBRE DEL TRABAJADOR UNIDADES PRODUCIDAS");
System.out.println("--------------------------------------------");
totTrab = 0;
totProdGral = 0;
for (t=1; t<=15; t++)
{
System.out.println("\n------------ Entrada de datos ------------");
System.out.print("Teclee nombre: ");
datoEntrada = flujoEntrada.readLine();
nombreTra = datoEntrada;
totProd = 0;
for (d=1; d<=6; d++)
{
System.out.print("Teclee produccion del dia: ");
datoEntrada = flujoEntrada.readLine();
proDia = Integer.parseInt(datoEntrada);
totProd = totProd + proDia;
}
System.out.println("\n----------------- Salida -----------------");
System.out.println("Nombre = " + nombreTra);
System.out.println("Unidades producidas = " + totProd);
totTrab = totTrab + 1;
totProdGral = totProdGral + totProd;
}
System.out.println("\n------------------ Total -----------------");
System.out.println("Total trabajadores = " + totTrab);
System.out.println("Total produccion general = " + totProdGral);
}
catch (IOException error)
{
System.err.println("Error " + error.getMessage());
}
}
}
import java.io.*;
public class Alumnos1
{
public static void main(String args[])
{
InputStreamReader entrada = new InputStreamReader(System.in);
BufferedReader flujoEntrada = new BufferedReader(entrada);
String datoEntrada;
String nombreAlum="";
int totAlumnos;
float calif1=0, calif2=0, calif3=0, calif4=0, promedio, promCal1, promCal2,
promCal3, promCal4, promProm, totCal1, totCal2, totCal3, totCal4,
totProm;
char desea=' ';
System.out.println("\n CALCULA CALIFICACIONES DE ALUMNOS\n");
try
{
System.out.println(" ANALISIS DE CALIFICACIONES");
System.out.print(" NOMBRE CAL.1 CAL.2");
System.out.println(" CAL.3 CAL.4 PROMEDIO");
System.out.print("-------------------------------------------");
System.out.println("------------------------");
totAlumnos = 0;
totCal1 = 0; totCal2 = 0; totCal3 = 0;
totCal4 = 0; totProm = 0;
do
{
System.out.println("-------------- Entrada de datos --------------");
System.out.print("Teclee nombre: ");
datoEntrada = flujoEntrada.readLine();
nombreAlum = datoEntrada;
System.out.print("Teclee calificacion 1: ");
datoEntrada = flujoEntrada.readLine();
calif1 = Float.parseFloat(datoEntrada);
System.out.print("Teclee calificacion 2: ");
datoEntrada = flujoEntrada.readLine();
calif2 = Float.parseFloat(datoEntrada);
System.out.print("Teclee calificacion 3: ");
datoEntrada = flujoEntrada.readLine();
calif3 = Float.parseFloat(datoEntrada);
System.out.print("Teclee calificacion 4: ");
datoEntrada = flujoEntrada.readLine();
calif4 = Float.parseFloat(datoEntrada);
promedio = (calif1 + calif2 + calif3 + calif4) / 4;
System.out.println("\n------------------- Salida -------------------");
System.out.println("Nombre = " + nombreAlum);
System.out.println("Calificacion 1 = " + calif1);
System.out.println("Calificacion 2 = " + calif2);
System.out.println("Calificacion 3 = " + calif3);
System.out.println("Calificacion 4 = " + calif4);
System.out.println("Promedio = " + promedio);
totAlumnos = totAlumnos + 1;
totCal1 = totCal1 + calif1;
totCal2 = totCal2 + calif2;
totCal3 = totCal3 + calif3;
totCal4 = totCal4 + calif4;
totProm = totProm + promedio;
System.out.print("\n¿Desea procesar otro alumno(S/N)?: ");
desea = (char)System.in.read();
System.in.skip(2);
} while (desea == 'S' || desea == 's');
promCal1 = totCal1 / totAlumnos;
promCal2 = totCal2 / totAlumnos;
promCal3 = totCal3 / totAlumnos;
promCal4 = totCal4 / totAlumnos;
promProm = totProm / totAlumnos;
System.out.println("\n------------- Promedios Generales ------------");
System.out.println("Promedio Calificacion 1 = " + promCal1);
System.out.println("Promedio Calificacion 2 = " + promCal2);
System.out.println("Promedio Calificacion 3 = " + promCal3);
System.out.println("Promedio Calificacion 4 = " + promCal4);
System.out.println("Promedio de promedios = " + promProm);
}
catch (IOException error)
{
System.err.println("Error " + error.getMessage());
}
}
}
------------------------------------------------------------------------------------------------------------------------------------
import java.io.*;
public class Alumnos2
{
public static void main(String args[])
{
InputStreamReader entrada = new InputStreamReader(System.in);
BufferedReader flujoEntrada = new BufferedReader(entrada);
String datoEntrada;
String nombreAlum="";
int totAprobados, totReprobados;
float calif1=0, calif2=0, calif3=0, calif4=0, caliFinal;
String observacion;
char desea=' ';
System.out.println("\n CALCULA CALIFICACIONES DE ALUMNOS\n");
try
{
System.out.println(" CALIFICACIONES FINALES");
System.out.print(" NOMBRE CAL.1 CAL.2");
System.out.println(" CAL.3 CALIF.FINAL OBSERVACION");
System.out.print("-------------------------------------------");
System.out.println("---------------------------------");
totAprobados = 0;
totReprobados = 0;
do
{
System.out.println("-------------- Entrada de datos --------------");
System.out.print("Teclee nombre: ");
datoEntrada = flujoEntrada.readLine();
nombreAlum = datoEntrada;
System.out.print("Teclee calificacion 1: ");
datoEntrada = flujoEntrada.readLine();
calif1 = Float.parseFloat(datoEntrada);
System.out.print("Teclee calificacion 2: ");
datoEntrada = flujoEntrada.readLine();
calif2 = Float.parseFloat(datoEntrada);
System.out.print("Teclee calificacion 3: ");
datoEntrada = flujoEntrada.readLine();
calif3 = Float.parseFloat(datoEntrada);
caliFinal = (calif1 * 0.2F) + (calif2 * 0.3F) + (calif3 *0.5F);
if (caliFinal >= 60)
{
totAprobados = totAprobados + 1;
observacion = "Aprobado";
}
else
{
totReprobados = totReprobados + 1;
observacion = "Reprobado";
}
System.out.println("\n------------------- Salida -------------------");
System.out.println("Nombre = " + nombreAlum);
System.out.println("Calificacion 1 = " + calif1);
System.out.println("Calificacion 2 = " + calif2);
System.out.println("Calificacion 3 = " + calif3);
System.out.println("Calificacion final = " + caliFinal);
System.out.println("Observacion = " + observacion);
System.out.print("\n¿Desea procesar otro alumno(S/N)?: ");
desea = (char)System.in.read();
System.in.skip(2);
} while (desea == 'S' || desea == 's');
System.out.println("\n------------------- Totales ------------------");
System.out.println("Total Aprobados = " + totAprobados);
System.out.println("Total Reprobados = " + totReprobados);
}
catch (IOException error)
{
System.err.println("Error " + error.getMessage());
}
}
}
--------------------------------------------------------------------------------------------------------------------------------------
import java.io.*;
public class ArticulosInfla
{
public static void main(String args[])
{
InputStreamReader entrada = new InputStreamReader(System.in);
BufferedReader flujoEntrada = new BufferedReader(entrada);
String datoEntrada;
String articulo="", articuloMayor="";
int totArticulos;
float precioAct=0, precioAnt=0, ptjeInfla, totInfla,
mayorInfla, promInfla;
char otro=' ';
System.out.println("\n PROCESA INFLACION DE VARIOS ARTICULOS\n");
try
{
System.out.println(" ANALISIS DE INFLACION");
System.out.println(" PRECIO PRECIO PORCENTAJE");
System.out.println(" ARTICULO ANTERIOR ACTUAL INFLACION");
System.out.println("-------------------------------------------------------------");
totArticulos = 0;
totInfla = 0;
mayorInfla = 0;
do
{
System.out.println("-------------- Entrada de datos --------------");
System.out.print("Teclee Articulo: ");
datoEntrada = flujoEntrada.readLine();
articulo = datoEntrada;
System.out.print("Teclee Precio Anterior: ");
datoEntrada = flujoEntrada.readLine();
precioAnt = Float.parseFloat(datoEntrada);
System.out.print("Teclee Precio Actual: ");
datoEntrada = flujoEntrada.readLine();
precioAct = Float.parseFloat(datoEntrada);
ptjeInfla = ((precioAct - precioAnt) / precioAnt) * 100;
System.out.println("\n------------------- Salida -------------------");
System.out.println("Articulo = " + articulo);
System.out.println("Precio Anterior = " + precioAnt);
System.out.println("Precio Actual = " + precioAct);
System.out.println("Porcentaje de Inflacion = " + ptjeInfla);
if (ptjeInfla > mayorInfla)
{
mayorInfla = ptjeInfla;
articuloMayor = articulo;
}
totArticulos = totArticulos + 1;
totInfla = totInfla + ptjeInfla;
System.out.print("\n¿Desea procesar otro articulo(S/N)?: ");
otro = (char)System.in.read();
System.in.skip(2);
} while (otro == 'S' || otro == 's');
promInfla = totInfla / totArticulos;
System.out.println("\n------------------- Totales ------------------");
System.out.println("Promedio de Inflacion = " + promInfla);
System.out.println("Articulo con Mayor Inflacion = " + articuloMayor);
System.out.println("Porcentaje Mayor de Inflacion = " + mayorInfla);
}
catch (IOException error)
{
System.err.println("Error " + error.getMessage());
}
}
}
------------------------------------------------------------------------------------------------------------------------------------
import java.io.*;
public class Clientes1
{
public static void main(String args[])
{
InputStreamReader entrada = new InputStreamReader(System.in);
BufferedReader flujoEntrada = new BufferedReader(entrada);
String datoEntrada;
String nombreClie="";
int tipoClie=0, cantidad=0, totClientes;
float precioUni=0, subTotal, descuento=0, netoPagar,
totSubTot,totDescuento, totNeto;
char desea=' ';
System.out.println("\n PROCESA VARIOS CLIENTES\n");
try
{
System.out.println(" REPORTE DE CLIENTES");
System.out.print(" NOMBRE SUB.TOTAL ");
System.out.println("DESCUENTO TOTAL A PAGAR");
System.out.print("---------------------------------------------");
System.out.println("----------------------------");
totClientes = 0;
totSubTot = 0;
totDescuento = 0;
totNeto = 0;
do
{
System.out.println("-------------- Entrada de datos --------------");
System.out.print("Teclee nombre: ");
datoEntrada = flujoEntrada.readLine();
nombreClie = datoEntrada;
System.out.print("Teclee tipo de cliente (1-4): ");
datoEntrada = flujoEntrada.readLine();
tipoClie = Integer.parseInt(datoEntrada);
System.out.print("Teclee cantidad de piezas compradas: ");
datoEntrada = flujoEntrada.readLine();
cantidad = Integer.parseInt(datoEntrada);
System.out.print("Teclee precio unitario: ");
datoEntrada = flujoEntrada.readLine();
precioUni = Float.parseFloat(datoEntrada);
subTotal = cantidad * precioUni;
switch (tipoClie)
{
case 1:
descuento = subTotal * 0.05F;
break;
case 2:
descuento = subTotal * 0.08F;
break;
case 3:
descuento = subTotal * 0.12F;
break;
case 4:
descuento = subTotal * 0.15F;
break;
}
netoPagar = subTotal - descuento;
System.out.println("\n------------------- Salida -------------------");
System.out.println("Nombre = " + nombreClie);
System.out.println("Subtotal = " + subTotal);
System.out.println("Descuento = " + descuento);
System.out.println("Neto a pagar = " + netoPagar);
totClientes = totClientes + 1;
totSubTot = totSubTot + subTotal;
totDescuento = totDescuento + descuento;
totNeto = totNeto + netoPagar;
System.out.print("\n¿Desea procesar otro cliente(S/N)?: ");
desea = (char)System.in.read();
System.in.skip(2);
} while (desea == 'S' || desea == 's');
System.out.println("\n------------------- Totales ------------------");
System.out.println("Total Clientes = " + totClientes);
System.out.println("Total Sub Total = " + totSubTot);
System.out.println("Total Descuento = " + totDescuento);
System.out.println("Total Neto a Pagar = " + totNeto);
}
catch (IOException error)
{
System.err.println("Error " + error.getMessage());
}
}
}
----------------------------------------------------------------------------------------------------------------------------------
import java.io.*;
public class Clientes2
{
public static void main(String args[])
{
InputStreamReader entrada = new InputStreamReader(System.in);
BufferedReader flujoEntrada = new BufferedReader(entrada);
String datoEntrada;
String nombreClie="", articulo="";
char otro=' ', hay=' ';
int totClientes, cantidad;
float precio, totPagar, totPagarClie, totPagarGral;
System.out.println("\n PROCESA LA VENTA A VARIOS CLIENTES\n");
try
{
System.out.println(" REPORTE DE VENTAS");
System.out.println("NOMBRE ARTICULO TOTAL PAGAR");
System.out.println("--------------------------------------------");
totClientes = 0;
totPagarGral = 0;
do
{
System.out.println("\n------------ Entrada de datos ------------");
System.out.print("Teclee nombre: ");
datoEntrada = flujoEntrada.readLine();
nombreClie = datoEntrada;
System.out.println("Nombre = " + nombreClie);
totPagarClie = 0;
do
{
System.out.print("Teclee articulo: ");
datoEntrada = flujoEntrada.readLine();
articulo = datoEntrada;
System.out.print("Teclee cantidad de articulos: ");
datoEntrada = flujoEntrada.readLine();
cantidad = Integer.parseInt(datoEntrada);
System.out.print("Teclee precio unitario: ");
datoEntrada = flujoEntrada.readLine();
precio = Float.parseFloat(datoEntrada);
totPagar = cantidad * precio;
System.out.println("Articulo = " + articulo);
System.out.println("Total a Pagar = " + totPagar);
totPagarClie = totPagarClie + totPagar;
System.out.print("\n¿Desea procesar otro articulo(S/N)?: ");
hay = (char)System.in.read();
System.in.skip(2);
} while (hay == 'S' || hay == 's');
System.out.println("Total pagar cliente = " + totPagarClie);
totClientes = totClientes + 1;
totPagarGral = totPagarGral + totPagarClie;
System.out.print("\n¿Desea procesar otro cliente(S/N)?: ");
otro = (char)System.in.read();
System.in.skip(2);
} while (otro == 'S' || otro == 's');
System.out.println("\n------------------ Total -----------------");
System.out.println("Total clientes = " + totClientes);
System.out.println("Total pagar general = " + totPagarGral);
}
catch (IOException error)
{
System.err.println("Error " + error.getMessage());
}
}
}
------------------------------------------------------------------------------------------------------------------------------------
import java.io.*;
public class Cuadratica3
{
public static void main(String args[])
{
double a=0, b=0, c=0, raizUnica, parteReal, parteImaginaria,
raizReal1, raizReal2;
System.out.println("\n REALIZA CALCULOS CON LA ECUACION CUADRATICA\n");
System.out.println(" A B C TIENE RAIZ 1 RAIZ 2");
System.out.println("---------------------------------------------");
a = 0;
do
{
a = a + 1;
c = c - a;
b = a - c;
System.out.print(a + " " + b + " " + c);
if ((Math.pow(b,2)-4*a*c) == 0)
{
raizUnica = -b/(2*a);
System.out.println(" Raiz unica " + raizUnica);
}
else
if ((Math.pow(b,2)-4*a*c) < 0)
{
parteReal = -b/(2*a);
parteImaginaria = Math.sqrt(Math.abs(Math.pow(b,2)-4*a*c))/(2*a);
System.out.print(" Raices complejas ");
System.out.println(" Parte real Parte imaginaria");
System.out.println(parteReal + " + " + parteImaginaria);
System.out.println(parteReal + " - " + parteImaginaria);
}
else
{
raizReal1 = -b + Math.sqrt(Math.pow(b,2)-4*a*c)/(2*a);
raizReal2 = -b - Math.sqrt(Math.pow(b,2)-4*a*c)/(2*a);
System.out.print(" Raices reales ");
System.out.println(raizReal1 + " " + raizReal2);
}
} while (a != 5);
}
}
--------------------------------------------------------------------------------------------------------------------------------------
import java.io.*;
public class Empleados1
{
public static void main(String args[])
{
InputStreamReader entrada = new InputStreamReader(System.in);
BufferedReader flujoEntrada = new BufferedReader(entrada);
String datoEntrada;
String nombreEmp="";
int horasTrab=0;
float cuotaHora=0;
float sueldo;
char desea=' ';
System.out.println("\n CALCULA EL SUELDO DE VARIOS EMPLEADOS");
try
{
do
{
System.out.println("\n------------ Entrada de datos ------------");
System.out.print("Teclee nombre: ");
datoEntrada = flujoEntrada.readLine();
nombreEmp = datoEntrada;
System.out.print("Teclee horas trabajadas: ");
datoEntrada = flujoEntrada.readLine();
horasTrab = Integer.parseInt(datoEntrada);
System.out.print("Teclee cuota por hora: ");
datoEntrada = flujoEntrada.readLine();
cuotaHora = Float.parseFloat(datoEntrada);
sueldo = horasTrab * cuotaHora;
System.out.println("\n----------------- Salida -----------------");
System.out.println("Nombre = " + nombreEmp);
System.out.println("Sueldo = " + sueldo);
System.out.print("\n¿Desea procesar otro empleado(S/N)?: ");
desea = (char)System.in.read();
System.in.skip(2);
} while (desea == 'S' || desea == 's');
}
catch (IOException error)
{
System.err.println("Error " + error.getMessage());
}
}
}
-----------------------------------------------------------------------------------------------------------------------------------
import java.io.*;
public class Empleados2
{
public static void main(String args[])
{
InputStreamReader entrada = new InputStreamReader(System.in);
BufferedReader flujoEntrada = new BufferedReader(entrada);
String datoEntrada;
String nombreEmp="";
int horasTrab=0, totEmpleados;
float cuotaHora=0;
float sueldo, totSueldos;
char desea=' ';
System.out.println("\n CALCULA EL SUELDO DE VARIOS EMPLEADOS");
try
{
System.out.println(" REPORTE DE EMPLEADOS");
System.out.println(" NOMBRE SUELDO");
System.out.println("------------------------------------------");
totEmpleados = 0;
totSueldos = 0;
do
{
System.out.println("\n------------ Entrada de datos ------------");
System.out.print("Teclee nombre: ");
datoEntrada = flujoEntrada.readLine();
nombreEmp = datoEntrada;
System.out.print("Teclee horas trabajadas: ");
datoEntrada = flujoEntrada.readLine();
horasTrab = Integer.parseInt(datoEntrada);
System.out.print("Teclee cuota por hora: ");
datoEntrada = flujoEntrada.readLine();
cuotaHora = Float.parseFloat(datoEntrada);
sueldo = horasTrab * cuotaHora;
System.out.println("\n----------------- Salida -----------------");
System.out.println("Nombre = " + nombreEmp);
System.out.println("Sueldo = " + sueldo);
totEmpleados = totEmpleados + 1;
totSueldos = totSueldos + sueldo;
System.out.print("\n¿Desea procesar otro empleado(S/N)?: ");
desea = (char)System.in.read();
System.in.skip(2);
} while (desea == 'S' || desea == 's');
System.out.println("\n------------------ Total -----------------");
System.out.println("Total empleados = " + totEmpleados);
System.out.println("Total sueldos = " + totSueldos);
}
catch (IOException error)
{
System.err.println("Error " + error.getMessage());
}
}
}
------------------------------------------------------------------------------------------------------------------------------------
import java.io.*;
public class EquivalenciasFahr2
{
public static void main(String args[])
{
float fahrenheit, celsius;
System.out.println("\nCALCULA EQUIVALENCIAS FAHRENHEIT CELSIUS\n");
System.out.println("Fahrenheit Celsius");
System.out.println("-------------------------------");
fahrenheit = 0;
do
{
fahrenheit = fahrenheit + 1;
celsius = (5F/9F) * (fahrenheit-32);
System.out.println(fahrenheit + " " + celsius);
} while (fahrenheit != 65);
}
}
-----------------------------------------------------------------------------------------------------------------------------------
import java.io.*;
public class ImprimeNumeros3
{
public static void main(String args[])
{
int i;
System.out.println("\nIMPRIME LOS NUMEROS DEL 1 AL 10\n");
i = 0;
do
{
i = i + 1;
System.out.println(i);
} while (i < 10);
}
}
------------------------------------------------------------------------------------------------------------------------------------
import java.io.*;
public class Logaritmos2
{
public static void main(String args[])
{
double x, senoX, cosenoX, arcoTanX;
System.out.println("\nCALCULA SENO COSENO ARCO TANGENTE DE -1 HASTA 1\n");
System.out.println(" X Seno X Coseno X Arco tangente X");
System.out.println("----------------------------------------------------");
x = -1.2;
do
{
x = x + 0.2;
senoX = Math.sin(x);
cosenoX = Math.cos(x);
arcoTanX = Math.atan(x);
System.out.println(x + " " + senoX + " " + cosenoX +" " + arcoTanX);
} while (x != 1);
}
}
----------------------------------------------------------------------------------------------------------------------------------
import java.io.*;
public class Obreros1
{
public static void main(String args[])
{
InputStreamReader entrada = new InputStreamReader(System.in);
BufferedReader flujoEntrada = new BufferedReader(entrada);
String datoEntrada;
String nombreObr="", obrMayor="", obrMenor="";
int proDia=0, totProd, toTotProd, totObreros, mayorProd, menorProd;
char otro=' ', desea=' ';
System.out.println("\n PROCESA LA PRODUCCION DE VARIOS OBREROS\n");
try
{
System.out.println(" REPORTE DE PRODUCCION");
System.out.println("NOMBRE DEL OBRERO TOTAL PRODUCCION");
System.out.println("--------------------------------------------");
totObreros = 0;
toTotProd = 0;
mayorProd = 0;
menorProd = 10000;
do
{
System.out.println("\n------------ Entrada de datos ------------");
System.out.print("Teclee nombre: ");
datoEntrada = flujoEntrada.readLine();
nombreObr = datoEntrada;
totProd = 0;
do
{
System.out.print("Teclee produccion del dia: ");
datoEntrada = flujoEntrada.readLine();
proDia = Integer.parseInt(datoEntrada);
totProd = totProd + proDia;
System.out.print("\n¿Desea procesar otro Dia(S/N)?: ");
otro = (char)System.in.read();
System.in.skip(2);
} while (otro == 'S' || otro == 's');
System.out.println("\n----------------- Salida -----------------");
System.out.println("Nombre = " + nombreObr);
System.out.println("Unidades producidas = " + totProd);
if (totProd > mayorProd)
{
mayorProd = totProd;
obrMayor = nombreObr;
}
if (totProd < menorProd)
{
menorProd = totProd;
obrMenor = nombreObr;
}
totObreros = totObreros + 1;
toTotProd = toTotProd + totProd;
System.out.print("\n¿Desea procesar otro obrero(S/N)?: ");
desea = (char)System.in.read();
System.in.skip(2);
} while (desea == 'S' || desea == 's');
System.out.println("\n------------------ Total -----------------");
System.out.println("Total obreros = " + totObreros);
System.out.println("Total produccion = " + toTotProd);
System.out.println("Nombre Obrero mas Productivo = " + obrMayor);
System.out.println("Produccion que Fabrico= " + mayorProd);
System.out.println("Nombre Obrero menos Productivo = " + obrMenor);
System.out.println("Produccion que Fabrico= " + menorProd);
}
catch (IOException error)
{
System.err.println("Error " + error.getMessage());
}
}
}
-----------------------------------------------------------------------------------------------------------------------------------
import java.io.*;
public class ValoresXYZ2
{
public static void main(String args[])
{
double x, y, z;
System.out.println("\nIMPRIME VALORES DE X Y Z\n");
System.out.println(" VALORES DE X Y Z");
System.out.println(" X Y Z");
System.out.println("----------------------");
x = 0;
do
{
x = x + 0.5;
y = 3 * Math.pow(x,2) + 7 * x - 15;
z = y - 2 * Math.pow(x,2);
System.out.println(x + " " + y + " " + z);
} while (x < 10);
}
}
-----------------------------------------------------------------------------------------------------------------------------------
import java.io.*;
public class Vendedores1
{
public static void main(String args[])
{
InputStreamReader entrada = new InputStreamReader(System.in);
BufferedReader flujoEntrada = new BufferedReader(entrada);
String datoEntrada;
String nombreVend="", articulo="";
char otro=' ', hay=' ';
int totVend, cantidad, clave;
float precio, totVendido, incentivo=0, totIncentivo,
venta, totGralIncentivo, totGralVenta;
System.out.println("\n PROCESA LA VENTA DE VARIOS VENDEDORES\n");
try
{
System.out.println(" REPORTE DE INCENTIVOS");
System.out.println("NOMBRE ARTICULO TOTAL PAGAR");
System.out.println("--------------------------------------------");
totVend = 0;
totGralVenta = 0;
totGralIncentivo = 0;
do
{
System.out.println("\n------------ Entrada de datos ------------");
System.out.print("Teclee nombre: ");
datoEntrada = flujoEntrada.readLine();
nombreVend = datoEntrada;
totVendido = 0;
totIncentivo = 0;
do
{
System.out.print("Teclee articulo: ");
datoEntrada = flujoEntrada.readLine();
articulo = datoEntrada;
System.out.print("Teclee clave de venta (1,2,3,4): ");
datoEntrada = flujoEntrada.readLine();
clave = Integer.parseInt(datoEntrada);
System.out.print("Teclee cantidad de articulos: ");
datoEntrada = flujoEntrada.readLine();
cantidad = Integer.parseInt(datoEntrada);
System.out.print("Teclee precio unitario: ");
datoEntrada = flujoEntrada.readLine();
precio = Float.parseFloat(datoEntrada);
venta = cantidad * precio;
switch (clave)
{
case 1:
incentivo = venta * 0.15F;
break;
case 2:
incentivo = venta * 0.1F;
break;
case 3:
incentivo = venta * 0.05F;
break;
case 4:
incentivo = venta * 0.03F;
break;
}
totVendido = totVendido + venta;
totIncentivo = totIncentivo + incentivo;
System.out.print("\n¿Desea procesar otro articulo(S/N)?: ");
hay = (char)System.in.read();
System.in.skip(2);
} while (hay == 'S' || hay == 's');
System.out.println("Nombre = " + nombreVend);
System.out.println("Total vendido = " + totVendido);
System.out.println("Total incentivo = " + totIncentivo);
totVend = totVend + 1;
totGralVenta = totGralVenta + totVendido;
totGralIncentivo = totGralIncentivo + totIncentivo;
System.out.print("\n¿Desea procesar otro vendedor(S/N)?: ");
otro = (char)System.in.read();
System.in.skip(2);
} while (otro == 'S' || otro == 's');
System.out.println("\n------------------ Total -----------------");
System.out.println("Total vendedores = " + totVend);
System.out.println("Total general venta = " + totGralVenta);
System.out.println("Total general incentivo = " + totGralIncentivo);
}
catch (IOException error)
{
System.err.println("Error " + error.getMessage());
}
}
}
-------------------------------------------------------------------------------------------------------------------------------------
import java.io.*;
public class Vendedores2
{
public static void main(String args[])
{
InputStreamReader entrada = new InputStreamReader(System.in);
BufferedReader flujoEntrada = new BufferedReader(entrada);
String datoEntrada;
String nombreVend="", articulo="";
char hay=' ';
int totVend, cantidad, clave;
float precio, totVendido, incentivo=0, totIncentivo,
venta, totGralIncentivo, totGralVenta;
System.out.println("\n PROCESA LA VENTA DE 15 VENDEDORES\n");
try
{
System.out.println(" REPORTE DE INCENTIVOS");
System.out.println("NOMBRE ARTICULO TOTAL PAGAR");
System.out.println("--------------------------------------------");
totVend = 0;
totGralVenta = 0;
totGralIncentivo = 0;
do
{
System.out.println("\n------------ Entrada de datos ------------");
System.out.print("Teclee nombre: ");
datoEntrada = flujoEntrada.readLine();
nombreVend = datoEntrada;
totVendido = 0;
totIncentivo = 0;
do
{
System.out.print("Teclee articulo: ");
datoEntrada = flujoEntrada.readLine();
articulo = datoEntrada;
System.out.print("Teclee clave de venta (1,2,3,4): ");
datoEntrada = flujoEntrada.readLine();
clave = Integer.parseInt(datoEntrada);
System.out.print("Teclee cantidad de articulos: ");
datoEntrada = flujoEntrada.readLine();
cantidad = Integer.parseInt(datoEntrada);
System.out.print("Teclee precio unitario: ");
datoEntrada = flujoEntrada.readLine();
precio = Float.parseFloat(datoEntrada);
venta = cantidad * precio;
switch (clave)
{
case 1:
incentivo = venta * 0.15F;
break;
case 2:
incentivo = venta * 0.1F;
break;
case 3:
incentivo = venta * 0.05F;
break;
case 4:
incentivo = venta * 0.03F;
break;
}
totVendido = totVendido + venta;
totIncentivo = totIncentivo + incentivo;
System.out.print("\n¿Desea procesar otro articulo(S/N)?: ");
hay = (char)System.in.read();
System.in.skip(2);
} while (hay == 'S' || hay == 's');
System.out.println("Nombre = " + nombreVend);
System.out.println("Total vendido = " + totVendido);
System.out.println("Total incentivo = " + totIncentivo);
totVend = totVend + 1;
totGralVenta = totGralVenta + totVendido;
totGralIncentivo = totGralIncentivo + totIncentivo;
} while (totVend != 15);
System.out.println("\n------------------ Total -----------------");
System.out.println("Total vendedores = " + totVend);
System.out.println("Total general venta = " + totGralVenta);
System.out.println("Total general incentivo = " + totGralIncentivo);
}
catch (IOException error)
{
System.err.println("Error " + error.getMessage());
}
}
}
------------------------------------------------------------------------------------------------------------------------------------
import java.io.*;
public class Vendedores3
{
public static void main(String args[])
{
InputStreamReader entrada = new InputStreamReader(System.in);
BufferedReader flujoEntrada = new BufferedReader(entrada);
String datoEntrada;
String nombreVend="";
char otro=' ';
int totVend, dia, mejorDia=0;
float ventaDia, totVenta, totVentaGral, mayorVenta;
System.out.println("\n PROCESA LA VENTA DE VARIOS VENDEDORES\n");
try
{
System.out.println(" REPORTE SEMANAL DE VENTAS");
System.out.println("NOMBRE VENTA SEMANAL DIA MAYOR VENTA");
System.out.println("-----------------------------------------------");
totVend = 0;
totVentaGral = 0;
do
{
System.out.println("\n------------ Entrada de datos ------------");
System.out.print("Teclee nombre: ");
datoEntrada = flujoEntrada.readLine();
nombreVend = datoEntrada;
totVenta = 0;
mayorVenta = 0;
for (dia=1; dia<=6; dia++)
{
System.out.print("Teclee venta del dia: ");
datoEntrada = flujoEntrada.readLine();
ventaDia = Float.parseFloat(datoEntrada);
totVenta = totVenta + ventaDia;
if (ventaDia > mayorVenta)
{
mayorVenta = ventaDia;
mejorDia = dia;
}
}
System.out.println("\n----------------- Salida -----------------");
System.out.println("Nombre = " + nombreVend);
System.out.println("Total venta = " + totVenta);
System.out.println("Mejor dia = " + mejorDia);
totVend = totVend + 1;
totVentaGral = totVentaGral + totVenta;
System.out.print("\n¿Hay otro vendedor(S/N)?: ");
otro = (char)System.in.read();
System.in.skip(2);
} while (otro == 'S' || otro == 's');
System.out.println("\n------------------ Total -----------------");
System.out.println("Total vendedores = " + totVend);
System.out.println("Total general venta = " + totVentaGral);
}
catch (IOException error)
{
System.err.println("Error " + error.getMessage());
}
}
}
----------------------------------------------------------------------------------------------------------------------------------
import java.io.*;
public class VendedoresAutos
{
public static void main(String args[])
{
InputStreamReader entrada = new InputStreamReader(System.in);
BufferedReader flujoEntrada = new BufferedReader(entrada);
String datoEntrada;
String nombreVend="";
char otro=' ', desea=' ';
int totAutos, totVend;
float precioAuto, salMin, sueldo, totSueldos, totVendido;
System.out.println("\nPROCESA LAS VENTAS DE VENDEDORES DE AUTOS\n");
try
{
System.out.print("Teclee salario minimo quincenal: ");
datoEntrada = flujoEntrada.readLine();
salMin = Float.parseFloat(datoEntrada);
System.out.println("\n NOMINA QUINCENAL");
System.out.println(" NOMBRE SUELDO");
System.out.println("------------------------------------------");
totSueldos = 0;
totVend = 0;
do
{
System.out.println("\n------------ Entrada de datos ------------");
System.out.print("Teclee nombre: ");
datoEntrada = flujoEntrada.readLine();
nombreVend = datoEntrada;
totAutos = 0;
totVendido = 0;
System.out.print("\n¿Hay auto vendido(S/N)?: ");
otro = (char)System.in.read();
System.in.skip(2);
while (otro == 'S' || otro == 's')
{
System.out.print("Teclee precio del auto: ");
datoEntrada = flujoEntrada.readLine();
precioAuto = Float.parseFloat(datoEntrada);
totAutos = totAutos + 1;
totVendido = totVendido + precioAuto;
System.out.print("\n¿Hay otro auto vendido(S/N)?: ");
otro = (char)System.in.read();
System.in.skip(2);
}
sueldo = salMin + (totAutos*100.00F) + (totVendido*0.02F);
System.out.println("\n----------------- Salida -----------------");
System.out.println("Nombre = " + nombreVend);
System.out.println("Sueldo = " + sueldo);
totVend = totVend + 1;
totSueldos = totSueldos + sueldo;
System.out.print("\n¿Desea procesar otro vendedor(S/N)?: ");
desea = (char)System.in.read();
System.in.skip(2);
} while (desea == 'S' || desea == 's');
System.out.println("\n------------------ Total -----------------");
System.out.println("Total vendedores = " + totVend);
System.out.println("Total sueldos = " + totSueldos);
}
catch (IOException error)
{
System.err.println("Error " + error.getMessage());
}
}
}
Suscribirse a:
Entradas (Atom)