Vous êtes sur la page 1sur 67

INSTITUTO TECNOLOGICO SUPERIOR DE ALAMO TEMAPACHE

REPORTE DE PRÁCTICAS
CARRERA:

Ingeniería en TICS

ASIGNATURA:

PROGRAMACION ORIENTADA A OBJETOS

NOMBRE DE LA PRÁCTICA:

Familiarización con el Entorno Java

NÚMERO DE LA PRÁCTICA:

01

GABRIEL CRUZ MORATO

SEMESTRE:

Segundo semestre

GRUPO:

201A

R01/0216 F-JC-51
INSTITUTO TECNOLOGICO SUPERIOR DE ALAMO TEMAPACHE

REPORTE DE PRÁCTICAS
INTRODUCCIÓN:
Existen algoritmos cuyas operaciones se deben de ejecutar un número repetido de
veces. Esto es, las
instrucciones son las mismas pero los datos varían. El conjunto de instrucciones
que se ejecutan
repetidamente se llama ciclo. Un ciclo tiene un número finito de veces de
ejecución. Un ciclo tiene una
condición para seguir ejecutándose o para terminar. Esto es, todo ciclo tiene una
condición de fin de ejecución.
En los algoritmos que se conoce el número de veces que se repite el ciclo, se dice
que se establece a priori.
Esto significa que el número de veces de repetición no depende de los datos. Este
tipo de algoritmo se le llama
repetir n veces el ciclo donde n es un número conocido. Cuando no se conoce el
número de veces a repetir el
ciclo, esto es, que no se puede establecer a priori el número de veces que ha de
ejecutarse el ciclo sino que
depende del tipo de datos y de las instrucciones de repeti ción, el algoritmo se
ejecuta mientras sucede una
condición de ejecución.
La estructura repetir conocida como la instrucción FOR, es la estructura
algorítmica que se utiliza en un ciclo
que se ejecuta un número definido de veces. Esta estructura está definida en
cualquier lenguaje de
programación.
La Estructura Repetitiva mientras que se utiliza cuando no se conoce el número de
veces de repetición. Esto
es, el número de repeticiones depende de las instrucciones y la información a
procesar (datos).
Esta estructura debe de estar compuesta de dos partes:
 Ciclo: las instrucciones que se ejecutan repetidamente
 Condición de terminación: la evaluación que decide cuando se termina el ciclo.

COMPETENCIA A DESARROLLAR:
Al completar esta práctica de laboratorio, el alumno podrá ser capaz:
 El alumno se familiarizara con el entorno de programación, tanto mediante la
interfaz gráfica
(Netbeans) como mediante la línea de comandos. Para ello se utilizará un
programa sencillo que se
compilará y ejecutará.

MATERIAL Y EQUIPO (REQUERIMIENTOS):


Equipo necesario:
 Computadora Personal
 Software Netbeans IDE 8.x

R01/0216 F-JC-51
INSTITUTO TECNOLOGICO SUPERIOR DE ALAMO TEMAPACHE

REPORTE DE PRÁCTICAS
DESARROLLO:
1. Hacer doble-click en el icono de NetBeans IDE en el escritorio (Figura-1) para
iniciar el IDE NetBeans.
Aparece la página de inicio de NetBeans
2. Seleccionar File del menú principal y seleccionar la opción New Project.
3. Observar que aparece el diálogo de New Project.
4. Seleccionar Java en la sección Categories y Java Application en la sección
Projects. (Figura-4)
5. Hacer click en el botón Next.
En la sección Name and Location, en el campo Project Name, escribir el nombre
que le queramos dar a nuestro proyecto.
6. En el campo Create Main Class, escribir el nombre que le queramos dar a
nuestra clase principal.
7. Dejar la opción Set as Main Project seleccionado.
8. Hacer click en el botón Finish.
9. ahora podemos empezar a escribir nuestro código.

Material de Apoyo
1. Hacer un programa que sume dos números leídos por teclado y escribir el resultado.
Código:
/*
* To change this license header, choose License Headers in Project
Properties.
* To change this template file, choose Tools | Templates
* and open the template in the editor.
*/
package ejercicios;

import java.util.Scanner;

/**
*
* @author GABRIEL CRUZ MORATO
*/
public class Ejercicios {

/**
* @param args the command line arguments
*/
public static void main(String[] args) {
// Ejercicio 1 Hacer un programa que sume dos números leídos por
teclado y escribir el resultado.

R01/0216 F-JC-51
INSTITUTO TECNOLOGICO SUPERIOR DE ALAMO TEMAPACHE

REPORTE DE PRÁCTICAS
Scanner num = new Scanner(System.in);
int n1;
int n2;

System.out.println("Introduce el primer número:");


n1 = num.nextInt();
System.out.println("Introduce el segundo número:");
n2 = num.nextInt();
int resultado = n1+n2;
System.out.println("La suma es " + n1 + " + " + n2 + " = " +
resultado);
}

}
Ejecución:

2. Modificar el anterior pero para sumar 10 números leídos por


teclado.
CODIGO:
/*
* To change this license header, choose License Headers in Project
Properties.
* To change this template file, choose Tools | Templates
* and open the template in the editor.
*/

R01/0216 F-JC-51
INSTITUTO TECNOLOGICO SUPERIOR DE ALAMO TEMAPACHE

REPORTE DE PRÁCTICAS
package ejercicios;

import java.util.Scanner;

/**
*
* @author GABRIEL CRUZ MORATO
*/
public class Ejercicio2 {

/**
* @param args the command line arguments
*/
public static void main(String[] args) {
// Ejercicio 2 Modificar el anterior pero para sumar 10 números leídos
por teclado.
Scanner num = new Scanner(System.in);
int n1,n2,n3,n4,n5,n6,n7,n8,n9,n10;
System.out.println("Introduce el primer número:");
n1 = num.nextInt();
System.out.println("Introduce el siguiente número:");
n2 = num.nextInt();
System.out.println("Introduce el siguiente número:");
n3 = num.nextInt();
System.out.println("Introduce el siguiente número:");
n4 = num.nextInt();
System.out.println("Introduce el siguiente número:");
n5 = num.nextInt();
System.out.println("Introduce el siguiente número:");
n6 = num.nextInt();
System.out.println("Introduce el siguiente número:");
n7 = num.nextInt();
System.out.println("Introduce el siguiente número:");
n8 = num.nextInt();
System.out.println("Introduce el siguiente número:");
n9 = num.nextInt();
System.out.println("Introduce el siguiente número:");
n10 = num.nextInt();
int resultado = n1+n2+n3+n4+n5+n6+n7+n8+n9+n10;
System.out.println("La suma total es " + resultado);
R01/0216 F-JC-51
INSTITUTO TECNOLOGICO SUPERIOR DE ALAMO TEMAPACHE

REPORTE DE PRÁCTICAS
}

}
EJECUCION:

3. Modificar el anterior para que permita sumar N números. El


valor de N se debe leer previamente por teclado.
CODIGO:
/*
* To change this license header, choose License Headers in Project
Properties.
* To change this template file, choose Tools | Templates
* and open the template in the editor.
*/
package ejercicio3;
import java.util.Scanner;
/**
*
* @author GABRIEL CRUZ MORATO
*/
public class Ejercicio3 {
/**
* @param args the command line arguments
*/
public static void main(String[] args) {

R01/0216 F-JC-51
INSTITUTO TECNOLOGICO SUPERIOR DE ALAMO TEMAPACHE

REPORTE DE PRÁCTICAS
// TODO code application logic here
int total=0;
Scanner num = new Scanner(System.in);
System.out.println("escribe el numero de veces que quieres que se
repita");
int n= num.nextInt();
for(int i=0;i<n;i++){
System.out.print("Ingresa un numero : ");
int numero=num.nextInt();
total=total+numero;
}
System.out.println("La suma de los "+n+" numeros que ingreso es :
"+total);
}
}
EJECUCUCION:

4. Elabora un programa que convierta un x número de galones en


litros, ten en cuenta que hay 3.7854 litros en un galón
CODIGO:
/*
* To change this license header, choose License Headers in Project
Properties.
* To change this template file, choose Tools | Templates
* and open the template in the editor.

R01/0216 F-JC-51
INSTITUTO TECNOLOGICO SUPERIOR DE ALAMO TEMAPACHE

REPORTE DE PRÁCTICAS
*/
package ejercicio4;
import java.util.Scanner;
/**
*
* @author GABRIEL CRUZ MORATO
*/
public class Ejercicio4 {

/**
* @param args the command line arguments
*/
public static void main(String[] args) {
// TODO code application logic here
Scanner num = new Scanner(System.in);
System.out.println("captura un numero de galones para convertilo
en litros");
int galon=num.nextInt();
float litro=(float) (galon*3.7854);
System.out.println("el numero de litros por galones es: "+litro);
}
}
EJECUCION:

R01/0216 F-JC-51
INSTITUTO TECNOLOGICO SUPERIOR DE ALAMO TEMAPACHE

REPORTE DE PRÁCTICAS
5. Modifica el programa para que imprima una tabla de
conversión desde 1 hasta 100 galones, cada 10 galones imprimirá
una línea de salida en blanco.
Código:
package ejercicio5;
/**
*
* @author GABRIEL CRUZ MORATO
*/
public class Ejercicio5 {
/**
* @param args the command line arguments
*/
public static void main(String[] args) {
// TODO code application logic here
float lt=(float) 3.7854;
for(int i=1;i<101;i++){
System.out.println("galon "+i+" es de: "+lt*i);
}
}
}
Ejecución:

R01/0216 F-JC-51
INSTITUTO TECNOLOGICO SUPERIOR DE ALAMO TEMAPACHE

REPORTE DE PRÁCTICAS
6. La gravedad de la Luna es de alrededor del 17% de la Tierra.
Escribe un programa que calcule su peso efectivo en la Luna.
CODIGO:
package ejercicio6;

import java.util.Scanner;

/**
*
* @author GABRIEL CRUZ MORATO
*/
public class Ejercicio6 {
public static void main(String[] args) {
Scanner peso = new Scanner(System.in);
System.out.println("introduce el peso");
float pe = peso.nextFloat();
float p2=(float) (pe*0.83);
System.out.println("el peso en la luna es "+p2);
}
}
EJECUCION:

R01/0216 F-JC-51
INSTITUTO TECNOLOGICO SUPERIOR DE ALAMO TEMAPACHE

REPORTE DE PRÁCTICAS
7. Elabora un programa que solicite la medida en Pies y realice la
conversión a pulgadas, yardas, cm y metros.
Toma en cuenta que un pie tiene 12 pulgadas y una pulgada
equivale a 2.54 cm.
Código:
/*
* To change this license header, choose License Headers in Project
Properties.
* To change this template file, choose Tools | Templates
* and open the template in the editor.
*/
package ejercicio7;
import java.util.Scanner;

/**
*
* @author GABRIEL CRUZ MORATO
*/
public class Ejercicio7 {
/**
* @param args the command line arguments
*/
public static void main(String[] args) {
// TODO code application logic here
Scanner pies = new Scanner(System.in);
System.out.println("introduce el peso");
float pe = pies.nextFloat();
float pulgadas=(float) (pe*12);
float yardas=(float) (pe*0.333);
float cm=(float) (pulgadas*2.54);
float metros=(float) (pe*0.3048);
System.out.println("la medida en pulgadas es: "+pulgadas);
System.out.println("la medida en yardas es: "+yardas);
System.out.println("la medida en centimetros es: "+cm);
System.out.println("la medida en metros es: "+metros);
}
}

R01/0216 F-JC-51
INSTITUTO TECNOLOGICO SUPERIOR DE ALAMO TEMAPACHE

REPORTE DE PRÁCTICAS
Ejecución:

8. Hacer un programa que permita escribir los primeros 100


números pares.
CODIGO:
/*
* To change this license header, choose License Headers in Project
Properties.
* To change this template file, choose Tools | Templates
* and open the template in the editor.
*/
package ejercicio8;
/**
*
* @author MOONLIGHT
*/
public class Ejercicio8 {
/**
* @param args the command line arguments
*/
public static void main(String[] args) {
// TODO code application logic here
for(int i=1;i<101;i++){
if(i%2==0)
System.out.println("numero: "+i);

R01/0216 F-JC-51
INSTITUTO TECNOLOGICO SUPERIOR DE ALAMO TEMAPACHE

REPORTE DE PRÁCTICAS
}
}
}
EJECUCION:

9. Hacer el programa que sume los N primeros impares. Realizar


después uno que haga lo mismo con los pares y, otro, con los
múltiplos de 3.
CODIGO:
/*
* To change this license header, choose License Headers in Project
Properties.
* To change this template file, choose Tools | Templates
* and open the template in the editor.
*/
package ejercicio9;

import java.util.Scanner;

/**
*
* @author GABRIEL CRUZ MORATO
*/
public class Ejercicio9 {

R01/0216 F-JC-51
INSTITUTO TECNOLOGICO SUPERIOR DE ALAMO TEMAPACHE

REPORTE DE PRÁCTICAS
/**
* @param args the command line arguments
*/
public static void main(String[] args) {
int pares = 0;
int impares = 0;
int multiplo = 0;
Scanner num = new Scanner(System.in);
System.out.println("introduce hasta que numero");
int limite = num.nextInt();
for (int i = 1; i <= limite; i++) {
if (i % 2 == 0) {
pares = pares + i;
}
if (i % 2 == 1) {
impares = impares + i;
}
if (i % 3 == 0) {
multiplo = multiplo + i;
}
}
System.out.println("suma de numeros pares: " + pares);
System.out.println("suma de numeros impares: " + impares);
System.out.println("suma de numeros multiplos de 3 : " +
multiplo);
}
}

R01/0216 F-JC-51
INSTITUTO TECNOLOGICO SUPERIOR DE ALAMO TEMAPACHE

REPORTE DE PRÁCTICAS
EJECUCION:

10. Hacer un programa que implementa el cálculo del área y el


perímetro de un círculo, dado un radio r, según las fórmulas área
= π * r 2 y perímetro = 2 *π * r.
Código:
/*
* To change this license header, choose License Headers in Project
Properties.
* To change this template file, choose Tools | Templates
* and open the template in the editor.
*/
package ejercicio10;
import java.util.Scanner;
/**
*
* @author GABRIEL CRUZ MORATO
*/
public class Ejercicio10 {
/**
* @param args the command line arguments
*/
public static void main(String[] args) {
// TODO code application logic here
Scanner num = new Scanner(System.in);

R01/0216 F-JC-51
INSTITUTO TECNOLOGICO SUPERIOR DE ALAMO TEMAPACHE

REPORTE DE PRÁCTICAS
System.out.println("introduce el radio");
float radio = num.nextFloat();
float area=(float) (3.1416*(radio*radio));
float perimetro=(float) ((2*3.1416)*radio);
System.out.println("el area es: "+area);
System.out.println("el perimetro es: "+perimetro);
}
}
Ejecución:

11. Suponga que un individuo desea invertir su capital en un


banco y desea saber cuánto dinero ganara después de un mes si
el banco paga a razón de 2% mensual.
CODIGO:
/*
* To change this license header, choose License Headers in Project
Properties.
* To change this template file, choose Tools | Templates
* and open the template in the editor.
*/
package ejercicio11;
import java.util.Scanner;
/**
*
* @author GABRIEL CRUZ MORATO

R01/0216 F-JC-51
INSTITUTO TECNOLOGICO SUPERIOR DE ALAMO TEMAPACHE

REPORTE DE PRÁCTICAS
*/
public class Ejercicio11 {
/**
* @param args the command line arguments
*/
public static void main(String[] args) {
// TODO code application logic here
Scanner num = new Scanner(System.in);
System.out.println("introduce la cantidad a invertir");
float inversion = num.nextFloat();
System.out.println("el dinero que ha ganado en este mes es:
"+inversion*0.02);
}
}
EJECUCION:

12. Un vendedor recibe un sueldo base más un 10% extra por


comisión de sus ventas, el vendedor desea saber cuánto dinero
obtendrá por concepto de comisiones por las tres ventas que
realiza en el mes y el total que recibirá en el mes tomando en
cuenta su sueldo base y comisiones.
CODIGO:
package ejercicio12;
import java.util.Scanner;
/**

R01/0216 F-JC-51
INSTITUTO TECNOLOGICO SUPERIOR DE ALAMO TEMAPACHE

REPORTE DE PRÁCTICAS
*
* @author GABRIEL CRUZ MORATO
*/
public class Ejercicio12 {
/**
* @param args the command line arguments
*/
public static void main(String[] args) {
// TODO code application logic here
Scanner num = new Scanner(System.in);
System.out.println("introduce el sueldo base");
float sbase = num.nextFloat();
System.out.println("introduce el total por las ventas");
float ventas = num.nextFloat();
float stotal = (float) (sbase+(ventas*0.10));
System.out.println("el sueldo mas la comision por las ventas es
"+stotal);
}
}
EJECUCION:

13. Una tienda ofrece un descuento del 15% sobre el total de la


compra y un cliente desea saber cuánto deberá pagar finalmente
por su compra.
CODIGO:
package ejercicio13;

R01/0216 F-JC-51
INSTITUTO TECNOLOGICO SUPERIOR DE ALAMO TEMAPACHE

REPORTE DE PRÁCTICAS
import java.util.Scanner;
/**
*
* @author GABRIEL CRUZ MORATO
*/
public class Ejercicio13 {
/**
* @param args the command line arguments
*/
public static void main(String[] args) {
// TODO code application logic here
Scanner num = new Scanner(System.in);
System.out.println("introduce el total de la compra");
float compra = num.nextFloat();
float total = (float) (compra*0.85);
System.out.println("el total de la compra mas comision es:
"+total);
}
}
EJECUCION:

14. Un alumno desea saber cuál será su calificación final en la


materia de Algoritmos. Dicha calificación se compone de los
siguientes porcentajes:
55% del promedio de sus tres calificaciones parciales.

R01/0216 F-JC-51
INSTITUTO TECNOLOGICO SUPERIOR DE ALAMO TEMAPACHE

REPORTE DE PRÁCTICAS
30% de la calificación del examen final.
15% de la calificación de un trabajo final.
CODIGO:
/*
* To change this license header, choose License Headers in Project
Properties.
* To change this template file, choose Tools | Templates
* and open the template in the editor.
*/
package ejercicio14;
import java.util.Scanner;
/**
*
* @author GABRIEL CRUZ MORATO
*/
public class Ejercicio14 {
/**
* @param args the command line arguments
*/
public static void main(String[] args) {
// TODO code application logic here
Scanner num = new Scanner(System.in);
System.out.println("introduce el promedio de tus 3 parciales");
float pparciales = num.nextFloat();
System.out.println("introduce la calificacion del examen final");
float efinal = num.nextFloat();
System.out.println("introduce la calificacion del trabajo final");
float tfinal = num.nextFloat();
float promedio =(float) ((float) (pparciales*0.55)+(efinal*0.30)+
(tfinal*0.15));
System.out.println("el promedio es: "+promedio);
}
}

R01/0216 F-JC-51
INSTITUTO TECNOLOGICO SUPERIOR DE ALAMO TEMAPACHE

REPORTE DE PRÁCTICAS
EJECUCION:

15. Dada una cantidad en pesos, obtener la equivalencia en


dólares, asumiendo que la unidad cambiaría es un dato
desconocido.
CODIGO:
/*
* To change this license header, choose License Headers in Project
Properties.
* To change this template file, choose Tools | Templates
* and open the template in the editor.
*/
package ejercicio15;
import java.util.Scanner;
/**
*
* @author GABRIEL CRUZ MORATO
*/
public class Ejercicio15 {
/**
* @param args the command line arguments
*/
public static void main(String[] args) {
// TODO code application logic here
Scanner num = new Scanner(System.in);

R01/0216 F-JC-51
INSTITUTO TECNOLOGICO SUPERIOR DE ALAMO TEMAPACHE

REPORTE DE PRÁCTICAS
System.out.println("introduce una cantidad en pesos");
float pesos = num.nextFloat();
System.out.println("introduce el precio de1 dolar en pesos");
float dolar = num.nextFloat();
System.out.println("la cantidad de pesos en dolares es:
"+pesos/dolar);
}
}
EJECUCION:

16. Calcular el nuevo salario de un obrero si obtuvo un


incremento del 25% sobre su salario anterior.
CODIGO:
/*
* To change this license header, choose License Headers in Project
Properties.
* To change this template file, choose Tools | Templates
* and open the template in the editor.
*/
package ejercicio16;
import java.util.Scanner;
/**
*
* @author MOONLIGHT
*/

R01/0216 F-JC-51
INSTITUTO TECNOLOGICO SUPERIOR DE ALAMO TEMAPACHE

REPORTE DE PRÁCTICAS
public class Ejercicio16 {
/**
* @param args the command line arguments
*/
public static void main(String[] args) {
// TODO code application logic here
Scanner num = new Scanner(System.in);
System.out.println("introduce el salario");
float salario = num.nextFloat();
System.out.println("el nuevo salario es de: "+salario*1.25);
}
}
EJECUCION:

17. En un hospital existen tres áreas: Ginecología, Pediatría,


traumatología. El presupuesto anual del
hospital se reparte conforme a la siguiente tabla:
Área Porcentaje del presupuesto
Ginecología 40%
Traumatología 30%
Pediatría 30%
Obtener la cantidad de dinero que recibirá cada área, para
cualquier monto presupuestal.
CODIGO:
package ejercicio17;

R01/0216 F-JC-51
INSTITUTO TECNOLOGICO SUPERIOR DE ALAMO TEMAPACHE

REPORTE DE PRÁCTICAS
import java.util.Scanner;
/**
* @author GABRIEL CRUZ MORATO
*/
public class Ejercicio17 {
/**
* @param args the command line arguments
*/
public static void main(String[] args) {
// TODO code application logic here
Scanner num = new Scanner(System.in);
System.out.println("introduce el presupuesto anual");
float presupuesto = num.nextFloat();
System.out.println("Ginecologia: "+presupuesto*0.40);
System.out.println("Traumatologia: "+presupuesto*0.30);
System.out.println("Pediatria: "+presupuesto*0.30);
}
}
EJECUCION:

18. El dueño de una tienda compra un artículo a un precio


determinado. Obtener el precio en que lo debe vender para
obtener una ganancia del 30%
CODIGO:
package ejercicio18;

R01/0216 F-JC-51
INSTITUTO TECNOLOGICO SUPERIOR DE ALAMO TEMAPACHE

REPORTE DE PRÁCTICAS
import java.util.Scanner;
/**
*
* @author MOONLIGHT
*/
public class Ejercicio18 {
/**
* @param args the command line arguments
*/
public static void main(String[] args) {
// TODO code application logic here
Scanner num = new Scanner(System.in);
System.out.println("introduce el precio al que compra un articulo");
float precio = num.nextFloat();
System.out.println("el precio al que debe venderlo es:
"+precio*1.30);
}
}
EJECUCION:

19. Todos los lunes, miércoles y viernes, una persona corre la


misma ruta y cronometra los tiempos obtenidos. Determinar el
tiempo promedio que la persona tarda en recorrer la ruta en una
semana cualquiera.
CODIGO:

R01/0216 F-JC-51
INSTITUTO TECNOLOGICO SUPERIOR DE ALAMO TEMAPACHE

REPORTE DE PRÁCTICAS
/*
* To change this license header, choose License Headers in Project
Properties.
* To change this template file, choose Tools | Templates
* and open the template in the editor.
*/
package ejercicio19;
import java.util.Scanner;
/**
*
* @author GABRIEL CRUZ MORATO
*/
public class Ejercicio19 {
/**
* @param args the command line arguments
*/
public static void main(String[] args) {
// TODO code application logic here
Scanner num = new Scanner(System.in);
System.out.println("introduce el tiempo que se tarda el lunes en
minutos: ");
float lunes = num.nextFloat();
System.out.println("introduce el tiempo que se tarda el miercoles
en minutos: ");
float miercoles = num.nextFloat();
System.out.println("introduce el tiempo que se tarda el viernes en
minutos: ");
float viernes = num.nextFloat();
float promedio =(lunes+miercoles+viernes)/3;
System.out.println("el tiempo que tarda en recorrer la ruta en una
semana cualquiera es de: "+promedio);
}
}

R01/0216 F-JC-51
INSTITUTO TECNOLOGICO SUPERIOR DE ALAMO TEMAPACHE

REPORTE DE PRÁCTICAS
EJECUCION:

20. Tres personas deciden invertir su dinero para fundar una


empresa. Cada una de ellas invierte una cantidad distinta.
Obtener el porcentaje que cada quien invierte con respecto a la
cantidad total invertida.
CODIGO:
/*
* To change this license header, choose License Headers in Project
Properties.
* To change this template file, choose Tools | Templates
* and open the template in the editor.
*/
package ejercicio20;
import java.util.Scanner;
/**
*
* @author GABRIEL CRUZ MORATO
*/
public class Ejercicio20 {
/**
* @param args the command line arguments
*/
public static void main(String[] args) {
// TODO code application logic here

R01/0216 F-JC-51
INSTITUTO TECNOLOGICO SUPERIOR DE ALAMO TEMAPACHE

REPORTE DE PRÁCTICAS
Scanner num = new Scanner(System.in);
System.out.println("introduce la inversion de la persona 1: ");
float p1 = num.nextFloat();
System.out.println("introduce la inversion de la persona 2: ");
float p2 = num.nextFloat();
System.out.println("introduce la inversion de la persona 3: ");
float p3 = num.nextFloat();
float total = p1 + p2 + p3;
System.out.println("porcentaje de inversion de la persona 1 es de:
" + ((p1 * 100) / total));
System.out.println("porcentaje de inversion de la persona 2 es de:
" + ((p2 * 100) / total));
System.out.println("porcentaje de inversion de la persona 3 es de:
" + ((p3 * 100) / total));
}
}
EJECUCION:

21. Desarrolle un algoritmo tal que dados los 3 lados de un


triángulo, pueda determinar su área. Esta la calculamos aplicando
la siguiente fórmula:

Dónde: Elevar n número a 0.5 es equivalente a la raíz cuadrada.

R01/0216 F-JC-51
INSTITUTO TECNOLOGICO SUPERIOR DE ALAMO TEMAPACHE

REPORTE DE PRÁCTICAS
CODIGO:
/*
* To change this license header, choose License Headers in Project
Properties.
* To change this template file, choose Tools | Templates
* and open the template in the editor.
*/
package ejercicio21;
import java.util.Scanner;

/**
*
* @author GABRIEL CRUZ MORATO
*/
public class Ejercicio21 {

/**
* @param args the command line arguments
*/
public static void main(String[] args) {
// TODO code application logic here
Scanner num = new Scanner(System.in);
System.out.println("introduce la medida de un lado: ");
float l1 = num.nextFloat();
System.out.println("introduce la medida de un lado: ");
float l2 = num.nextFloat();
System.out.println("introduce la medida de un lado: ");
float l3 = num.nextFloat();
float s= (l1+l2+l3)/2;
float total= (float) Math.sqrt(s*(s-l1)*(s-l2)*(s-l3));
System.out.println("el area es: "+total);
}
}

R01/0216 F-JC-51
INSTITUTO TECNOLOGICO SUPERIOR DE ALAMO TEMAPACHE

REPORTE DE PRÁCTICAS
EJECUCION:

22. Calcule e imprima el número de segundos que hay en un


determinado número de días.
CODIGO:
import java.util.Scanner;
/*
* To change this license header, choose License Headers in Project
Properties.
* To change this template file, choose Tools | Templates
* and open the template in the editor.
*/
/**
*
* @author GABRIEL CRUZ MORATO
*/
public class prog22 {
public static void main(String[] args) {
Scanner in = new Scanner(System.in);
System.out.println("numero de dias a segundos");
int dia=in.nextInt();
float seg=(dia*24*60)*60;
System.out.println("los segundos son "+seg);
}
}

R01/0216 F-JC-51
INSTITUTO TECNOLOGICO SUPERIOR DE ALAMO TEMAPACHE

REPORTE DE PRÁCTICAS
EJECUCION:

23. Dado como datos el radio y la altura de un cilindro, calcule e


imprima el área y su volumen.
Dónde:
Volumen = π * radio2 * altura
Área = 2 * π * radio * altura
Código:
/*
* To change this license header, choose License Headers in Project
Properties.
* To change this template file, choose Tools | Templates
* and open the template in the editor.
*/
package ejer23;
import java.util.Scanner;
/**
*
* @author GABRIEL CRUZ MORATO
*/
public class Ejer23 {
/**
* @param args the command line arguments
*/
public static void main(String[] args) {

R01/0216 F-JC-51
INSTITUTO TECNOLOGICO SUPERIOR DE ALAMO TEMAPACHE

REPORTE DE PRÁCTICAS
Scanner in = new Scanner(System.in);
System.out.println("pedir el radio");
int rad=in.nextInt();
System.out.println("pedir la altura");
int altura=in.nextInt();
float vol=(float) (3.1416*(rad*rad)*altura);
float area=(float) (2*3.1416*rad*altura);
System.out.println("el resultado es "+area +vol);
}
}
Ejecución:

24. Teniendo una distancia de 417 kms. De Ciudad Victoria a


Miguel Alemán. Calcule el tiempo de viaje en automóvil (Horas y
minutos), suponiendo una misma velocidad desde que sale, hasta
el arribo.
Código:
/*
* To change this license header, choose License Headers in Project
Properties.
* To change this template file, choose Tools | Templates
* and open the template in the editor.
*/
package ejer24;
import java.util.Scanner;

R01/0216 F-JC-51
INSTITUTO TECNOLOGICO SUPERIOR DE ALAMO TEMAPACHE

REPORTE DE PRÁCTICAS
/**
*
* @author GABRIEL CRUZ MORATO
*/
public class Ejer24 {
/**
* @param args the command line arguments
*/
public static void main(String[] args) {
Scanner in = new Scanner(System.in);
System.out.println("pedir la velocidad");
int velocidad=in.nextInt();
double viaje=417/velocidad;
System.out.println("el resultado es "+viaje +" horas");
}
}
Ejecución:

25. Una gasolinera despacha gasolina y la bomba surtidora


registra la compra en galones, pero el precio de la gasolina está
fijado en 8.20 el litro. Construya un algoritmo que calcule y
escriba cuanto hay que cobrarle al cliente si este consume “n”
galones.
Dónde:
1 Galón = 3.785 lts.

R01/0216 F-JC-51
INSTITUTO TECNOLOGICO SUPERIOR DE ALAMO TEMAPACHE

REPORTE DE PRÁCTICAS
Código:
package ejer25;
import java.util.Scanner;
/**
*
* @author GABRIEL CRUZ MORATO
*/
public class Ejer25 {
/**
* @param args the command line arguments
*/
public static void main(String[] args) {
Scanner in = new Scanner(System.in);
System.out.println("pedir galon");
int galon=in.nextInt();
float precio=(float) ((galon*3.785)*8.20);
System.out.println("el precio de la gasolina es "+precio);
}
}
Ejecución:

26. Construya un algoritmo que calcule la distancia entre dos puntos,


dado como datos las coordenadas de los puntos P1 y P2.

R01/0216 F-JC-51
INSTITUTO TECNOLOGICO SUPERIOR DE ALAMO TEMAPACHE

REPORTE DE PRÁCTICAS
Dónde:
X1, Y1 representan las coordenadas del punto P1 en el eje de las X, Y
X2, Y2 representan las coordenadas del punto P2 en el eje de las X, Y.
Consideraciones:
Para calcular la distancia “D” entre dos puntos dados P1 y P2
aplicamos la siguiente fórmula:

CODIGO:
/*
* To change this license header, choose License Headers in Project
Properties.
* To change this template file, choose Tools | Templates
* and open the template in the editor.
*/
package ejer26;
import java.util.Scanner;
/**
*
* @author GABRIEL CRUZ MORATO
*/
public class Ejer26 {
/**
* @param args the command line arguments
*/
public static void main(String[] args) {
Scanner in = new Scanner(System.in);
System.out.println("DAME X1");
int X1 = in.nextInt();
System.out.println("DAME Y1");
int Y1 = in.nextInt();
System.out.println("DAME X2");
int X2 = in.nextInt();
System.out.println("DAME Y2");
int Y2 = in.nextInt();
float d = (float) Math.sqrt(Math.pow((X1 - X2), 2) + Math.pow((Y1 -
Y2), 2));
System.out.println("LA DISTANCIA ENTRE LOS DOS PUNTOS D
ES: " + d);
}

R01/0216 F-JC-51
INSTITUTO TECNOLOGICO SUPERIOR DE ALAMO TEMAPACHE

REPORTE DE PRÁCTICAS
}
EJECUCION:

27. Desarrolle un algoritmo que determine si un número es par y


que escriba dicho número junto con el letrero “n es un número
par”
CODIGO:
/*
* To change this license header, choose License Headers in Project
Properties.
* To change this template file, choose Tools | Templates
* and open the template in the editor.
*/
package ejer27;
import java.util.Scanner;
/**
*
* @author GABRIEL CRUZ MORATO
*/
public class Ejer27 {
/**
* @param args the command line arguments
*/
public static void main(String[] args) {
Scanner in = new Scanner(System.in);

R01/0216 F-JC-51
INSTITUTO TECNOLOGICO SUPERIOR DE ALAMO TEMAPACHE

REPORTE DE PRÁCTICAS
System.out.println("pedir un numero");
int num=in.nextInt();
if(num%2==0)
System.out.println("el numero "+num +" es par");
else
System.out.println("el numero "+num +" es impar");
}
}
EJECUCION:

28. Dado como dato el sueldo de un trabajador, aplíquele un


aumento del 15% si su sueldo es inferior a $1,000.00. Escriba en
este caso el nuevo sueldo del trabajador. Haga el diagrama
correspondiente y su prueba de escritorio.
CODIGO:
/*
* To change this license header, choose License Headers in Project
Properties.
* To change this template file, choose Tools | Templates
* and open the template in the editor.
*/
package ejer28;
import java.util.Scanner;
/**
*

R01/0216 F-JC-51
INSTITUTO TECNOLOGICO SUPERIOR DE ALAMO TEMAPACHE

REPORTE DE PRÁCTICAS
* @author GABRIEL CRUZ MORATO
*/
public class Ejer28 {
/**
* @param args the command line arguments
*/
public static void main(String[] args) {
Scanner in = new Scanner(System.in);
System.out.println("sueldo del trabajador");
int sueldo=in.nextInt();
if (sueldo<1000)
System.out.println("el sueldo es "+sueldo*1.15);
else
System.out.println("el sueldo es "+sueldo);
}
}
EJECUCION:

29. Hacer el algoritmo para escribir un programa que indique si un


número ingresado por el teclado es positivo.
CODIGO:
package numero.positivo;
import java.util.Scanner;
/**
*

R01/0216 F-JC-51
INSTITUTO TECNOLOGICO SUPERIOR DE ALAMO TEMAPACHE

REPORTE DE PRÁCTICAS
* @author GABRIEL CRUZ MORATO
*/
public class Ejercicio_29 {
/**
* @param args the command line arguments
*/
public static void main(String[] args) {
// TODO code application logic here
System.out.println("escribir el numero deseado");
Scanner in=new Scanner(System.in);
int numero = in.nextInt();
if (numero>0){
System.out.println("el numero es positivo");
}
else {
System.out.println("el numero es negativo");
}
}
}
EJECUCION:

30. Escriba un algoritmo que con base en tres valores enteros


(val1, val2, val3), determine cuál de ellos es el mayor.
CODIGO:

R01/0216 F-JC-51
INSTITUTO TECNOLOGICO SUPERIOR DE ALAMO TEMAPACHE

REPORTE DE PRÁCTICAS
* @author GABRIEL CRUZ MORATO
*/
import java.util.Scanner;
public class EJER30 {
public static void main(String[] args) {
Scanner in = new Scanner(System.in);
int n1, n2, n3;
System.out.print("Introduzca primer número: ");
n1 = in.nextInt();
System.out.print("Introduzca segundo número: ");
n2 = in.nextInt();
System.out.print("Introduzca tercer número: ");
n3 = in.nextInt();
if (n1 > n2) {
if (n1 > n3) {
System.out.println("El mayor es: " + n1);
} else {
System.out.println("el mayor es: " + n3);
}
} else if (n2 > n3) {
System.out.println("el mayor es: " + n2);
} else {
System.out.println("el mayor es: " + n3);
}
}
}

EJECUCION:

R01/0216 F-JC-51
INSTITUTO TECNOLOGICO SUPERIOR DE ALAMO TEMAPACHE

REPORTE DE PRÁCTICAS

31. Para que un alumno de la Politécnica pague $200 de


inscripción necesita sacar un promedio de 9 o más. Con base en
sus calificaciones, determine si alcanza este promedio y de ser
así escriba “El alumno tiene beca”
CODIGO:
/*
* To change this license header, choose License Headers in Project
Properties.
* To change this template file, choose Tools | Templates
* and open the template in the editor.
*/
package promedio.de.beca;
import java.util.Scanner;
/**
*
* @author GABRIEL CRUZ MORATO
*/
public class Ejercicio_31 {
/**
* @param args the command line arguments
*/
public static void main(String[] args) {
// TODO code application logic here
System.out.println("escribir promedio general de calificacion");

R01/0216 F-JC-51
INSTITUTO TECNOLOGICO SUPERIOR DE ALAMO TEMAPACHE

REPORTE DE PRÁCTICAS
Scanner in=new Scanner(System.in);
int promedio = in.nextInt();
if (promedio>=9){
System.out.println("el alumno tiene beca");
}
else{
System.out.println("el alumno no tiene beca");
}
}
}
EJECUCION:

32. El pasaje de Reynosa a Cd. Victoria cuesta $375.00 pesos,


pero la compañía de autobuses hace descuentos de 60% tercer
edad, 50% estudiantes, 35% menores de edad y 0% clientes
regulares. Escriba un algoritmo que aplique al precio del boleto el
descuento correspondiente según el tipo de persona que va a
viajar.
CODIGO:
/*
* To change this license header, choose License Headers in Project
Properties.
* To change this template file, choose Tools | Templates
* and open the template in the editor.
*/

R01/0216 F-JC-51
INSTITUTO TECNOLOGICO SUPERIOR DE ALAMO TEMAPACHE

REPORTE DE PRÁCTICAS
package ejercicio_32;
import java.util.Scanner;
/**
*
* @author GABRIEL CRUZ MORATO
*/
public class Ejercicio_32 {
/**
* @param args the command line arguments
*/
public static void main(String[] args) {
Scanner in=new Scanner(System.in);
int P,edad = 0,desc,to = 0;
System.out.println("Introduce tu edad:");
P = in.nextInt();
if (edad>50){
desc=(int) (375*.60);
to=375-desc;
}
if ((edad>=8||edad<=22)){
desc=(int) (375*.50);
to=375-desc;
}
if(edad>=0||edad<=5){
desc=(int)(375*.30);
to=375-desc;
}
System.out.println("El total es:"+to);
}
}

EJECUCION:

R01/0216 F-JC-51
INSTITUTO TECNOLOGICO SUPERIOR DE ALAMO TEMAPACHE

REPORTE DE PRÁCTICAS

33. La compañía Marinela lanza la promoción de 2 x 1 y medio en


todos sus productos. Desarrolle un algoritmo para el cobro de
estos productos, por ejemplo, si el cliente lleva 5, cobrar 4 dentro
de la promoción y uno con precio normal. Escriba el total a pagar.
CODIGO:
/*
* To change this license header, choose License Headers in Project
Properties.
* To change this template file, choose Tools | Templates
* and open the template in the editor.
*/
package ejercicio_33;
import java.util.Scanner;
/**
*
* @author GABRIEL CRUZ MORATO
*/
public class Ejercicio_33 {
/**
* @param args the command line arguments
*/
public static void main(String[] args) {
Scanner in=new Scanner(System.in);
int num,pro,to=0;

R01/0216 F-JC-51
INSTITUTO TECNOLOGICO SUPERIOR DE ALAMO TEMAPACHE

REPORTE DE PRÁCTICAS
System.out.println("Introduce el numero de productos");
num=in.nextInt();
System.out.println("El precio es:");
pro=in.nextInt();
if(num%2==0){
to=(pro/2)*num;
}
if(num%2==1){
to=((num/2)*pro)+pro;
}
System.out.println("La oferta es:"+to);
}
}
EJECUCION:

34. Tomando como base el algoritmo 08, controle el error que se


haría en el cálculo del total a pagar si la cantidad entrante fuera
un número negativo
CODIGO:
/*
* To change this license header, choose License Headers in Project
Properties.
* To change this template file, choose Tools | Templates
* and open the template in the editor.
*/

R01/0216 F-JC-51
INSTITUTO TECNOLOGICO SUPERIOR DE ALAMO TEMAPACHE

REPORTE DE PRÁCTICAS
package ejercicio.pkg34;
import java.util.Scanner;
/**
*
* @author GABRIEL CRUZ MORATO
*/
public class EJERCICIO34 {
/**
* @param args the command line arguments
*/
public static void main(String[] args) {
Scanner Entrada=new Scanner (System.in);
int num,suma=0;
for(num=1; num>=-200; num--){
System.out.println("");
if(num%2==0){
System.out.println(""+num--);
}
}
}
}
EJECUCION:

R01/0216 F-JC-51
INSTITUTO TECNOLOGICO SUPERIOR DE ALAMO TEMAPACHE

REPORTE DE PRÁCTICAS
35. Construya un algoritmo dado un número entero positivo,
determine y escriba si este número es par o impar.
CODIGO:
/*
* To change this license header, choose License Headers in Project
Properties.
* To change this template file, choose Tools | Templates
* and open the template in the editor.
*/
package ejercicio.pkg35;
import java.util.Scanner;
/**
*
* @author GABRIEL CRUZ MORATO
*/
public class EJERCICIO35 {
/**
* @param args the command line arguments
*/
public static void main(String[] args) {
// TODO code application logic here
Scanner Entrada=new Scanner (System.in);
int num,suma=0;
for(num=1; num>=-200; num--){
System.out.println("");
if(num%2==0){
System.out.println(""+num--);
}
}
}
}
EJECUCION:

R01/0216 F-JC-51
INSTITUTO TECNOLOGICO SUPERIOR DE ALAMO TEMAPACHE

REPORTE DE PRÁCTICAS

36. Con base en la edad proporcionada, determine y escriba si la


persona es mayor o menor de edad.
CODIGO:
/*
* To change this license header, choose License Headers in Project
Properties.
* To change this template file, choose Tools | Templates
* and open the template in the editor.
*/
package ejercicio36;
import java.util.Scanner;
/**
*
* @author GABRIEL CRUZ MORATO
*/
public class EJERCICIO36 {
/**
* @param args the command line arguments
*/
public static void main(String[] args) {
Scanner Entrada=new Scanner (System.in);
int edad;
System.out.println("Introdusca la edad ");
edad = Entrada.nextInt();

R01/0216 F-JC-51
INSTITUTO TECNOLOGICO SUPERIOR DE ALAMO TEMAPACHE

REPORTE DE PRÁCTICAS
if (edad>=18){
System.out.println("La persona es mayor de edad ");
}
else{
System.out.println("La persona es menor de edad ");
}
}
}
EJECUCION:

37. Dado un número entero positivo, verifique y escriba si se


encuentra en el rango de 0 a 20 ó es mayor que 20.
CODIGO:
/*
* To change this license header, choose License Headers in Project
Properties.
* To change this template file, choose Tools | Templates
* and open the template in the editor.
*/
package ejercicio.pkg37;
/**
*
* @author GABRIEL CRUZ MORATO
*/
import java.util.Scanner;

R01/0216 F-JC-51
INSTITUTO TECNOLOGICO SUPERIOR DE ALAMO TEMAPACHE

REPORTE DE PRÁCTICAS
public class Ejercicio37 {
/**
* @param args the command line arguments
*/
public static void main(String[] args) {
// TODO code application logic here
Scanner in = new Scanner(System.in);
System.out.println("Introdusca un numero ");
int num = in.nextInt();
if (num >=0 && num<=20) {
System.out.println("el numero "+num+ " esta en el rango de 0 a
20 ");
} else {
System.out.println("el numero "+num+ " NO esta en el rango de
0 a 20 ");
}
}
}
EJECUCION:

38. Construya un algoritmo que determine y escriba dado un


número entero positivo, si este es menor, mayor o igual que cero.
CODIGO:
/*

R01/0216 F-JC-51
INSTITUTO TECNOLOGICO SUPERIOR DE ALAMO TEMAPACHE

REPORTE DE PRÁCTICAS
* To change this license header, choose License Headers in Project
Properties.
* To change this template file, choose Tools | Templates
* and open the template in the editor.
*/
package ejercicio38;
import java.util.Scanner;

/**
*
* @author GABRIEL CRUZ MORATO
*/
public class Ejercicio38 {
/**
* @param args the command line arguments
*/
public static void main(String[] args) {
// TODO code application logic here
System.out.println("escriba un numero");
Scanner in=new Scanner(System.in);
int numero = in.nextInt();
if (numero>0){
System.out.println("el numero es mayor a cero y positivo");
}
if (numero<0){
System.out.println("el numero es menor a cero y negativo");{
}
if (numero==0){
System.out.println("el numero es cero");
}
}
}
}
EJECUCION:

R01/0216 F-JC-51
INSTITUTO TECNOLOGICO SUPERIOR DE ALAMO TEMAPACHE

REPORTE DE PRÁCTICAS

39. Dados 3 números enteros positivo, determine y escriba cual


es el mayor.
CODIGO:
package Ejercicio_39;
import java.util.Scanner;
/**
*
* @author GABRIEL CRUZ MORATO
*/
public class Ejercicio_39 {
/**
* @param args the command line arguments
*/
public static void main(String[] args) {
Scanner in=new Scanner(System.in);
// escribir un algoritmo con vase en tres valores enteros val, val2,
val3, determina cual de ellos es el mayor
System.out.println("escribe el valor 1");
int n1 = in.nextInt();
System.out.println("escribe el valor 2");
int n2 = in.nextInt();
System.out.println("escribe el valor 3");
int n3 = in.nextInt();
if((n1>n2)&(n2>n3)){

R01/0216 F-JC-51
INSTITUTO TECNOLOGICO SUPERIOR DE ALAMO TEMAPACHE

REPORTE DE PRÁCTICAS
System.out.println("El numero " +n1+ " es el mayor "+n2+" y
"+n3);}
if((n2>n1) & (n2>n3)){
System.out.println("El numero " +n2+ " es el mayor "+n1+" y
"+n3);}
if((n3>n1) & (n3>n2)){
System.out.println("El mayor " +n3+ " es el mayor "+n1+" y "+n2);
}}}
EJECUCION:

40. Dado como dato el sueldo de un trabajador, aplique un


aumento del 15% si su sueldo es inferior a $1000.00 y 12% en
caso contrario. Escriba el nuevo sueldo.
CODIGO:
/*
* To change this license header, choose License Headers in Project
Properties.
* To change this template file, choose Tools | Templates
* and open the template in the editor.
*/
package ejer40;
import java.util.Scanner;
/**
*
* @author GABRIEL CRUZ MORATO

R01/0216 F-JC-51
INSTITUTO TECNOLOGICO SUPERIOR DE ALAMO TEMAPACHE

REPORTE DE PRÁCTICAS
*/
public class Ejer40 {
/**
* @param args the command line arguments
*/
public static void main(String[] args) {
Scanner in = new Scanner(System.in);
System.out.println("sueldo del trabajador");
int sueldo=in.nextInt();
if (sueldo<1000)
System.out.println("el sueldo es "+sueldo*1.15);
else
System.out.println("el sueldo es "+sueldo*1.12);
}
}
EJECUCION:

41. Dados como datos la categoría y el sueldo de un trabajador,


calcule el aumento correspondiente teniendo en cuenta la
siguiente tabla. Imprimir la categoría del trabajador y el nuevo
sueldo.

R01/0216 F-JC-51
INSTITUTO TECNOLOGICO SUPERIOR DE ALAMO TEMAPACHE

REPORTE DE PRÁCTICAS
CODIGO:
/*
* To change this license header, choose License Headers in Project
Properties.
* To change this template file, choose Tools | Templates
* and open the template in the editor.
*/
package ejer41;
import java.util.Scanner;
/**
*
* @author GABRIEL CRUZ MORATO
*/
public class Ejer41 {
/**
* @param args the command line arguments
*/
public static void main(String[] args) {
Scanner in = new Scanner(System.in);
System.out.println("sueldo del trabajador");
int sueldo=in.nextInt();
System.out.println("pedir categoria");
int categoria=in.nextInt();
if (categoria==1)
System.out.println("el sueldo es "+sueldo*1.15);
if (categoria==2)
System.out.println("el sueldo es "+sueldo*1.10);
if (categoria==3)
System.out.println("el sueldo es "+sueldo*1.08);
if (categoria==4)
System.out.println("el sueldo es "+sueldo*1.07);
if(categoria<=0 || categoria >=5)
System.out.println("la categoria no existe");
}
}
EJECUCION:

R01/0216 F-JC-51
INSTITUTO TECNOLOGICO SUPERIOR DE ALAMO TEMAPACHE

REPORTE DE PRÁCTICAS

42. Desarrolle un algoritmo que muestre las opciones de cálculo


de área de un círculo, rectángulo y circunferencia. Escriba cuál
área fue calculada y su resultado.
CODIGO:
/*
* To change this license header, choose License Headers in Project
Properties.
* To change this template file, choose Tools | Templates
* and open the template in the editor.
*/
package ejer42;
import java.util.Scanner;

/**
*
* @author GABRIEL CRUZ MORATO
*/
public class Ejer42 {
/**
* @param args the command line arguments
*/
public static void main(String[] args) {
Scanner in = new Scanner(System.in);
System.out.println("escibe el numero");

R01/0216 F-JC-51
INSTITUTO TECNOLOGICO SUPERIOR DE ALAMO TEMAPACHE

REPORTE DE PRÁCTICAS
System.out.println("1 circulo");
System.out.println("2 rectangulo");
System.out.println("3 circunferencia");
int num=in.nextInt();
if (num==1){
System.out.println("escribe el radio");
int radio=in.nextInt();
float area=(float) (3.1416*(radio*radio));
System.out.println("el area es "+area);
}
if (num==2){
System.out.println("escribe el lado1");
int lado1=in.nextInt();
System.out.println("escribe el lado2");
int lado2=in.nextInt();
float area=(lado1*lado2);
System.out.println("el area es "+area);
}
if (num==3){
System.out.println("escribe el radio");
int radio=in.nextInt();
float circunferencia=(float) ((radio*2)*3.1416);
System.out.println("la circunferencia es "+circunferencia);
}
}
}

EJECUCION:

R01/0216 F-JC-51
INSTITUTO TECNOLOGICO SUPERIOR DE ALAMO TEMAPACHE

REPORTE DE PRÁCTICAS

43. Construya un algoritmo que escriba la fecha del día en el


formato “Hoy es Martes 15 de Febrero de 2011”, dado el número
de día de la semana, el día del mes y el año.
CODIGO:
/*
* To change this license header, choose License Headers in Project
Properties.
* To change this template file, choose Tools | Templates
* and open the template in the editor.
*/
package ejer43;
import java.util.Scanner;
/**
*
* @author GABRIEL CRUZ MORATO
*/
public class Ejer43 {
/**
* @param args the command line arguments
*/
public static void main(String[] args) {
Scanner in = new Scanner(System.in);
String dia,mes,año;
System.out.println("escibe que dia y numero es");

R01/0216 F-JC-51
INSTITUTO TECNOLOGICO SUPERIOR DE ALAMO TEMAPACHE

REPORTE DE PRÁCTICAS
dia =in.next();
System.out.println("escibe el mes");
mes=in.next();
System.out.println("escibe el año");
año=in.next();
System.out.println("hoy es "+dia+" de "+mes+" de "+año);
}
}
EJECUCION:

44. Desarrolle un algoritmo que dada una calificación escriba los


siguientes letreros

CODIGO:
/*
* To change this license header, choose License Headers in Project
Properties.
* To change this template file, choose Tools | Templates
* and open the template in the editor.
*/
package ejer44;
import java.util.Scanner;
R01/0216 F-JC-51
INSTITUTO TECNOLOGICO SUPERIOR DE ALAMO TEMAPACHE

REPORTE DE PRÁCTICAS
/**
*
* @author GABRIEL CRUZ MORATO
*/
public class Ejer44 {
/**
* @param args the command line arguments
*/
public static void main(String[] args) {
Scanner in = new Scanner(System.in);
System.out.println("pedir calificacion");
int calificacion1=in.nextInt();
if (calificacion1==10)
System.out.println("felicidades "+calificacion1);
if (calificacion1==9)
System.out.println("muy bien "+calificacion1);
if (calificacion1==8)
System.out.println("sigue adelante "+calificacion1);
}
}
EJECUCION:

R01/0216 F-JC-51
INSTITUTO TECNOLOGICO SUPERIOR DE ALAMO TEMAPACHE

REPORTE DE PRÁCTICAS
45. La COMAPA tiene su tarifa de cobro de servicio distribuida en
5 zonas, la cual obviamente tiene una variación en el precio del
consumo por m3 y se desglosa de la siguiente manera:

Desarrolle un algoritmo que calcule el total a pagar por consumo


de un mes y

escriba lo siguiente:
Zona No.:______
Ubicación: _____________
Consumo m3:___________
Total a pagar: $__________
CODIGO:
EJECUCION:

Algoritmo 46. Dados los datos A, B, C que representan números


enteros diferentes, construya un algoritmo para escribir estos
números en forma descendente.
CODIGO:
/*
* To change this license header, choose License Headers in Project
Properties.
* To change this template file, choose Tools | Templates
* and open the template in the editor.
*/
package ejerc46;
import java.util.Scanner;
/**
*
* @author GABRIEL CRUZ MORATO
*/
public class Ejerc46 {
/**
* @param args the command line arguments
*/
public static void main(String[] args) {
Scanner teclado = new Scanner(System.in);
int a,b,c,mayor,medio,menor;
R01/0216 F-JC-51
INSTITUTO TECNOLOGICO SUPERIOR DE ALAMO TEMAPACHE

REPORTE DE PRÁCTICAS
System.out.println("dado 3 numeros devolver los 3 en orden
ascendente");
System.out.println("ingrese el primer numero");
a=teclado.nextInt();
System.out.println("ingrese el segundo numero");
b=teclado.nextInt();
System.out.println("ingrese el tercer numero");
c=teclado.nextInt();
if(a>b&&a>c)
mayor=a;
else
if(b>a&&b>c)
mayor=b;
else
mayor=c;
if(a<b&&b<c)
menor=a;
else
if(b<a&&b<c)
menor=b;
else
menor=c;
medio=(a+b+c)-(mayor+menor);
System.out.println("");
System.out.println("el orden ascendente de los numeros
ingresados es:" );
System.out.println(menor+" "+medio+" "+mayor);
}
}

EJECUCION:

R01/0216 F-JC-51
INSTITUTO TECNOLOGICO SUPERIOR DE ALAMO TEMAPACHE

REPORTE DE PRÁCTICAS

Algoritmo 47. Construya un algoritmo de flujo tal que dado como


dato una temperatura en grados Fahrenheit, determine el deporte
que es apropiado practicar a esa temperatura, teniendo en cuenta
la siguiente tabla:

CODIGO:
/*
* To change this license header, choose License Headers in Project
Properties.
* To change this template file, choose Tools | Templates
* and open the template in the editor.
*/
package ejerc47;
import java.util.Scanner;
/**
*
* @author GABRIEL CRUZ MORATO
*/
public class Ejerc47 {
/**

R01/0216 F-JC-51
INSTITUTO TECNOLOGICO SUPERIOR DE ALAMO TEMAPACHE

REPORTE DE PRÁCTICAS
* @param args the command line arguments
*/
public static void main(String[] args) {
Scanner in = new Scanner(System.in);
System.out.println("pedir grados");
int grados=in.nextInt();
if (grados>30)
System.out.println("natacion");
if ((grados>20)&& (grados<=30))
System.out.println("tenis");
if ((grados>0)&&(grados<=20))
System.out.println("golf");
if (grados<=0)
System.out.println("esqui");
}
}
EJECUCION:

R01/0216 F-JC-51
INSTITUTO TECNOLOGICO SUPERIOR DE ALAMO TEMAPACHE

REPORTE DE PRÁCTICAS
CONCLUSIONES:
SE PUEDEN REALIZAR MULTIPLES PROGRAMAS A TRAVEZ DE
ESTE LENGUAJE DE PROGRAMACION, ME PARECIERON
BUENOS EJERCICIOS PARA PRACTICAR Y APRENDER MAS
SOBRE EL MANEJO DE ESTE SOFTWARE Y SINTAXIS DEL
LENGUAJE DE PROGRAMACION.

R01/0216 F-JC-51
INSTITUTO TECNOLOGICO SUPERIOR DE ALAMO TEMAPACHE

REPORTE DE PRÁCTICAS
BIBLIOGRAFIA
1. Ceballos J. (2007) Java 2 Lenguaje y aplicaciones. España:
Alfaomega.
2. Ceballos J. (2012) Microsoft C# -Curso de Programación. España:
Alfaomega.
3. Dean J. y Dean R. (2009) Introducción a la programación con Java:
McGraw Hill
4. Doyle, B (2013) C# Programming: From Problem Analysis to
Program Design. Cengage
Learning
5. Eckel, B. (2009) Piensa en Java. España: Prentice Hall.
6. Froufe, A. (2008) Java 2 Manual de usuario y tutorial. España:
Alfaomega
7. Groussard, T. (2011) Recursos Informáticos C#4 Los fundamentos
del lenguaje- desarrollar con
visual estudio 2010. España: Eni Ediciones
8. Joyanes, L. y Zahonero, I. (2011) Programación en Java 6. España:
McGraw Hill
9. Sierra, K. (2008) SCJP Sun Certified Programmer for Java 6. USA:
McGraw Hill.
10. Wu T. (2008) Programación en Java. Introducción a la
Programación Orientada a Objetos.
España: McGrawHill

REALIMENTACIÓN DEL DOCENTE:

R01/0216 F-JC-51
INSTITUTO TECNOLOGICO SUPERIOR DE ALAMO TEMAPACHE

REPORTE DE PRÁCTICAS

NOMBRE Y FIRMA NOMBRE Y FIRMA DEL DOCENTE:


(Integrantes del equipo)

ING. CINTHYA BERNABE PACHECO


GABRIEL CRUZ MORATO _____________________________

LUGAR DE LA PRÁCTICA:
SALON DE CLASES

FECHA DE REALIZACIÓN:
23 DE FEBRERO

R01/0216 F-JC-51

Vous aimerez peut-être aussi