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());
}
}
}

No hay comentarios:

Publicar un comentario