Beruflich Dokumente
Kultur Dokumente
Ejercicio 01:
Ejercicio 02:
public class jose02
{
public static void main(String args[])
{
System.out.println("¡Mi nombre es Jose Sanchez Gaona!");
System.out.println("¡Este es mi segundo programa en JAVA!");
System.out.println("son las 20 Horas con 50 minutos");
System.out.println("del 03 de Julio de 2019");
Errores:
Operadores
El signo + además de usarse para sumar se utiliza como signo de concatenación es decir: resultado =
variable1 + variable2
System.out.println("El resultado es:" + resultado);
Ejercicio: sumabasica:
int a = 4;
int resultado = 0;
resultado = a + 2;
Ejercicio: opbasicas1:
int a = 4;
int b = 3;
int c = 5;
int d = 6;
int resultado_1 = 0;
int resultado_2 = 0;
int a = 4;
int b = 3;
int c = 5;
int d = 6;
int resultado_1 = 0;
int resultado_2 = 0;
Ejercicio: opbasicas3:
public class opbasicas3
{
public static void main(String args[])
{
int a = 4;
int b = 3;
int c = 5;
int d = 6;
int resultado_1 = 0;
int resultado_2 = 0;
// Resultado_1 = 14 - 5
// Resultado_1 = 9
resultado_2 = ((resultado_1+c)/(d+a-8))*15/3;
// Resultado_2 = ((9+5)/(2))*5
// Resultado_2 = 7*5 = 35
int a = 4;
int b = 3;
int c = 5;
int d = 6;
int resultado_1 = 0;
int resultado_2 = 0;
// Resultado_1 = 14 - 5
// Resultado_1 = 9
resultado_2 = (resultado_1+c)/(d+a-8)*15/3;
// Resultado_2 = (9+5)/(2)*5
// Resultado_2 = 7*5 = 35
Ejercicio: condicionantes1:
int matematicas = 8;
int biologia = 5;
int quimica = 8;
int promedio = 0;
promedio = (matematicas+biologia+quimica)/3;
if(promedio >= 6)
{
System.out.println("El alumno aprobo " + promedio);
}
else
{
System.out.println("El alumno reprobo " + promedio);
}
}
}
Ejercicio: condicionantes2:
int matematicas = 5;
int biologia = 5;
int quimica = 4;
int promedio = 0;
promedio = (matematicas+biologia+quimica)/3;
if(promedio >= 6)
{
System.out.println("El alumno aprobo " + promedio);
}
else
{
if(promedio <= 4)
{
System.out.println("El alumno debe repetir" + promedio);
}
else
{
System.out.println("El saco 4" + promedio);
}
}
}
}
import java.util.Scanner; // Para captura de datos se requiere la librería útil y la sublibreria Scanner
System.out.println("****************************************************** ");
System.out.println("* SISTEMA DE INFORMACION DE VACACIONES CIA XY * ");
System.out.println("****************************************************** ");
}
System.out.println("Indiqueme el tiempo de antiguedad: ");
antiguedad = entrada.nextInt();
if(clave == 2)
{
departamento = "OPERACIONES";
if(antiguedad == 1)
{
vacaciones = 10;
}
if(antiguedad >= 2 && antiguedad <= 6)
{
vacaciones = 15;
}
if(antiguedad >= 7)
{
vacaciones = 22;
}
}
import java.util.Scanner;
System.out.println("************************************************ ");
System.out.println("* EJERCICIO ESTRUCTURAS DE CONTROL SWITCH-CASE * ");
System.out.println("************************************************ ");
if(opcion == 1)
{
System.out.println("Ingrese Numero uno: ");
numero_1 = entrada.nextInt();
}
if(opcion == 2)
{
System.out.println("Ingrese Numero dos: ");
numero_2 = entrada.nextInt();
}
if(opcion == 3)
{
System.out.println("Ingrese Numero tres: ");
numero_3 = entrada.nextInt();
}
if(opcion == 4)
{
System.out.println("Ingrese Numero cuatro: ");
numero_4 = entrada.nextInt();
}
switch(opcion)
{
case 1: resultado = numero_1 + 1;
System.out.println("El resultado de la opcion 1 es: " + resultado);
break;
}
}
}
System.out.println("Ciclo termino");
for (int i=1; i <= 5; i++)
{
System.out.print(i + " , " ); // El efecto es el mismo con el + antes ó despues
}
System.out.println("Ciclo termino");
}
}
{
public static void main(String args[])
{
int i = 1;
}
}
Ejercicio 02 (do-while):
{
public static void main(String args[])
{
int i = 1000;
while(i>=0)
{
System.out.println(+i);
i = i-200;// El decrecremento es el mismo **
}
while (i >= 0)
{
System.out.print(+ i + " , ");
i-=200; // El decrecremento es el mismo **
}
// Para dejar dos saltos
System.out.println();
System.out.println();
System.out.println( "** AHORA USANDO EL BUCLE do-while **");
i = 1000;
do
{
System.out.print(+i+" , ");
i-=200;
}
while (i>=0);
}
}