Вы находитесь на странице: 1из 8

Ingeniería Mecatrónica

Taller 14-09-2020
Programación Orientada a Objetos -
POO
camilo andres belalcazar

Abstract lista de elementos


ejercicio 1y2

package ejerciciou1y2;

Escribir el resumen breve de la practica y que se va a pre- public class Ejerciciou1y2 {


sentar en el informe. Documentación Descripción del
prototipo public static void main(String[] args) {
System.out.println("Camilo Andres Belalcazar");
System.out.println("popayan,cra 2A Num 1N-14 ");
System.out.println("Tel: 3102986634");

ejercicio 3

package ejercicio.pkg3;

public class Ejercicio3 {

1 Introducción /**
* @param args the command line arguments
*/
public static void main(String[] args) {
System.out.printf("%-10s %s\n", "dormir", "sleep");
System.out.printf("%-10s %s\n", "kid", "niño\\a");
System.out.printf("%-10s %s\n", "program", "programar");
talleres practicos libro guia System.out.printf("%-10s %s\n", "sport", "deporte");
System.out.printf("%-10s %s\n", "food", "comida");
System.out.printf("%-10s %s\n", "leg", "pierna");
System.out.printf("%-10s %s\n", "memory", "memoria");
System.out.printf("%-10s %s\n", "marker", "marcador");
System.out.printf("%-10s %s\n", "mobile", "celular");
System.out.printf("%-10s %s\n", "car", "carro");
// TODO code application logic here
}

1.1 Software

windows10pro

1
Ingeniería Mecatrónica

lista de elementos lista de elementos


ejercicio 4 EJERCICIO 6

package ejercicio.pkg4; package ejercicio6;

/** /**
* *
* @author Dell * @author Dell
*/ */
public class Ejercicio4 { public class Ejercicio6 {

/** /**
* @param args the command line arguments * @param args the command line arguments
*/ */
public static void main(String[] args) { public static void main(String[] args) {
System.out.println("Lunes\tMartes\tMiérc.\tJue c
,→ ves.\tViernes"); System.out.println(" *");
System.out.println("======\t=======\t====== c System.out.println(" ***");
,→ \t=======\t======="); System.out.println(" *****");
System.out.println("---\tlogicaG\t---\t--- \tlogica"); System.out.println(" *******");
System.out.println("---\tlogica\t---\t---\tlogica"); System.out.println("*********");
System.out.println("cated\t---\t---\tingles\t---"); // TODO code application logic here
System.out.println("estad\tadmin\talge\talge\tpo c }
,→ o");
System.out.println("estad\tadmin\talge\talge\tpo c }
,→ o");
System.out.println("estad\tadmin\talge\t---\tpoo");
// TODO code application logic here
}

}
EJERCICIO 5

package ejercicio5;
lista de elementos
EJERCICIO 7
/**
*
* @author Dell
package ejercicio7;
*/
public class Ejercicio5 {
/**
*
/**
* @author Dell
* @param args the command line arguments
*/
*/
public class Ejercicio7 {
public static void main(String[] args) {
String blanco = "\033[37";
/**
String rojo = "\033[31m";
* @param args the command line
String celeste = "\033[36m";
,→ arguments
String naranja = "\033[33m";
*/
String verde = "\033[32m";
public static void main(String[] args) {
String morado = "\033[35m";
System.out.println("hola mundo");
String azul = "\033[34m";
System.out.println(" *");
System.out.println(" * *");
System.out.println(azul+
System.out.println(" * *");
,→ "Lunes\tMartes\tMiérc.\tJueves.\tViernes");
System.out.println(" * *");
System.out.println("======\t=======\t====== c
System.out.println("*********");
,→ \t=======\t=======");
System.out.println(verde+"---\tlogicaG\t---\t---"+c c
// TODO code application logic here
,→ eleste+"\tlogica"); }
System.out.println(verde+"---\tlogica\t---\t---\tlogi c
,→ ca"); }
System.out.println(naranja+"cated\t---"+morado+" c
,→ \t---"+morado+"\tingles\t---");
System.out.println(naranja+"estad\tadmin\talge\t c
,→ alge\tpoo");
System.out.println(azul+"estad\tadmin\talge"+az c
,→ ul+"\talge\tpoo");
System.out.println(rojo+"estad\tadmin\talge\t---\ c
,→ tpoo"); 2
// TODO code application logic here
}
Ingeniería Mecatrónica

lista de elementos lista de elementos


EJERCICIO 8 EJERCICIO 10

package ejercicio8;
package ejercicio10;
/**
* /**
* @author Dell *
*/ * @author Dell
public class Ejercicio8 { */
public class Ejercicio10 {
/**
* @param args the command line /**
,→ arguments * @param args the command line
*/ ,→ arguments
public static void main(String[] args) */
,→ { public static void main(String[] args)
System.out.println("piramide ,→ {
,→ invertida"); int x = 144;
int y = 999;
System.out.println("*********");
System.out.println(" * *"); System.out.println("x = " + x);
System.out.println(" * *"); System.out.println("y = " + y);
System.out.println(" * *"); System.out.println("x + y = " + (x +
System.out.println(" *"); ,→ y));
System.out.println("x - y = " + (x - y));
// TODO code application logic System.out.println("x / y = " +
,→ here ,→ ((float)x / (float)y));
} System.out.println("x * y = " + (x * y));
// TODO code application logic
} ,→ here
}

lista de elementos
EJERCICIO 11

package ejercicio11;

/**
*
* @author Dell
*/
public class Ejercicio11 {

/**
* @param args the command line
,→ arguments
*/
public static void main(String[] args)
,→ {
String nombre = "Camilo Andres
,→ Belalcazar Bravo";
System.out.println(nombre);
// TODO code application logic
,→ here
}

3
Ingeniería Mecatrónica

lista de elementos lista de elementos


EJERCICIO 12 EJERCICIO 16

package ejercicio12; package ejercicio16;

/** /**
* *
* @author Dell * @author Dell
*/ */
public class Ejercicio12 { public class Ejercicio16 {

/** /**
* @param args the command line * @param args the command line
,→ arguments ,→ arguments
*/ */
public static void main(String[] args) public static void main(String[] args)
,→ { ,→ {
String dia;
String nombre = "camilo andres
,→ belalcazar bravo"; System.out.print("Por favor,
String direccion = "popayan - cra 2a ,→ introduzca un día de la semana
,→ num 1n-14"; ,→ y le diré qué asignatura toca a
String telefono = "Tel: 3102986634"; ,→ primera hora ese día: ");
System.out.println(nombre); dia = (System.console().readLine());
System.out.println(direccion); String toLowerCase =
System.out.println(telefono); ,→ dia.toLowerCase();
// TODO code application logic
,→ here switch(dia) {
} case "lunes":
System.out.println("catedra");
} System.out.println("estaistica");
case "martes":
System.out.println("ligica
,→ matematica");
System.out.println("fundamentos
,→ de administracion");
case "miércoles":
lista de elementos System.out.println("algebra
,→ lineal");
break;
EJERCICIO 13
case "jueves":
System.out.println("inglesuno");
package ejercicio13;
break;
case "viernes":
/**
System.out.println("logica
*
,→ matematica");
* @author Dell
System.out.println("poo");
*/
case "sábado":
public class Ejercicio13 {
System.out.println("¡Ese día no
,→ tienes clase!");
/**
case "domingo":
* @param args the command line
System.out.println("¡Ese día no
,→ arguments
,→ tiene clase!");
*/
break;
public static void main(String[] args)
default:
,→ {
System.out.println("El día
double dolares = 6.00;
,→ introducido no es correcto.");
int pesos = (int) (dolares * 3.500);
// TODO code application logic
,→ here
System.out.print(dolares + " dolares
}
,→ son " + pesos + " pesos.");
// TODO code application logic
}
,→ here
}
}

4
Ingeniería Mecatrónica

lista de elementos lista de elementos


EJERCICIO 17 EJERCICIO 18
/*
package ejercicio17; * To change this license header,
,→ choose License Headers in
/** ,→ Project Properties.
* * To change this template file, choose
* @author Dell ,→ Tools | Templates
*/ * and open the template in the editor.
public class Ejercicio17 { */
package ejercicio18;
/**
* @param args the command line /**
,→ arguments *
*/ * @author Dell
public static void main(String[] args) */
,→ { public class Ejercicio18 {
System.out.print("Por favor,
,→ introduzca una hora del día (0 - /**
,→ 23): "); * @param args the command line
int hora = Integer.parseInt(System. c ,→ arguments
,→ console().readLine()); */
public static void main(String[] args)
if ((hora >= 7) && (hora <= 11)) { ,→ {
System.out.println("Buenos días"); String dia;
}
System.out.print("Por favor,
if ((hora >= 15) && (hora <= 17)) { ,→ introduzca un número del 1 al
System.out.println("Buenas ,→ 7: ");
,→ tardes"); int n = Integer.parseInt(System.con c
} ,→ sole().readLine());

if (((hora >= 20) && (hora < 24)) || switch(n) {


,→ ((hora <= 23) && (hora >= 0))) { case 1:
System.out.println("Buenas dia = "lunes";
,→ noches"); break;
} case 2:
dia = "martes";
if ((hora >= 24) || (hora < 0)) { break;
System.out.println("La hora case 3:
,→ introducida no es correcta."); dia = "miércoles";
} break;
case 4:
} dia = "jueves";
break;
} case 5:
dia = "viernes";
break;
case 6:
dia = "sábado";
break;
case 7:
dia = "domingo";
break;
default:
dia = "Debe introducir un número
,→ del 1 al 7";
}

System.out.println(dia);
// TODO code application logic
,→ here
}

5
Ingeniería Mecatrónica

lista de elementos lista de elementos


EJERCICIO 19 EJERCICIO 20

package ejercicio20;
package ejercicio19;
/**
/** *
* * @author Dell
* @author Dell */
*/ public class Ejercicio20 {
public class Ejercicio19 {
/**
/** * @param args the command line
* @param args the command line ,→ arguments
,→ arguments */
*/ public static void main(String[] args)
public static void main(String[] args) ,→ {
,→ { System.out.println("Este
int sueldoSemanal; ,→ programa resuelve
,→ ecuaciones de primer grado
System.out.print("Por favor, ,→ del tipo ax + b = 0");
,→ introduzca el número de horas System.out.print("Por favor,
,→ trabajadas durante la semana: ,→ introduzca el valor de a: ");
,→ "); Double a = Double.parseDouble(Sy c
int horasTrabajadas = ,→ stem.console().readLine());
,→ Integer.parseInt(System.conso c System.out.print("Ahora introduzca
,→ le().readLine()); ,→ el valor de b: ");
Double b = Double.parseDouble(Sys c
if (horasTrabajadas < 40) { ,→ tem.console().readLine());
sueldoSemanal = 12 *
,→ horasTrabajadas; if (a == 0) {
} else { System.out.println("Esa ecuación
sueldoSemanal = (40 * 12) + ,→ no tiene solución real.");
,→ ((horasTrabajadas - 40) * 16); } else {
} System.out.println("x = " + (-b/a));
System.out.println("El sueldo }
,→ semanal que le corresponde es // TODO code application logic
,→ de " + sueldoSemanal + " ,→ here
,→ euros"); }
// TODO code application logic
,→ here }
}

6
Ingeniería Mecatrónica

lista de elementos lista de elementos


EJERCICIO 21 EJERCICIO 22
/* /*
* To change this license header, * To change this license header,
,→ choose License Headers in ,→ choose License Headers in
,→ Project Properties. ,→ Project Properties.
* To change this template file, choose * To change this template file, choose
,→ Tools | Templates ,→ Tools | Templates
* and open the template in the editor. * and open the template in the editor.
*/ */
package ejercicio21; package ejercicio22;

/** /**
* *
* @author Dell * @author Dell
*/ */
public class Ejercicio21 { public class Ejercicio22 {

/** /**
* @param args the command line * @param args the command line
,→ argumen ,→ arguments
*/ */
final static double g = 9.81; public static void main(String[] args)
,→ {
public static void main(String[] args) System.out.println("Este programa
,→ { ,→ calcula la media de tres
System.out.println("Cálculo del ,→ notas.");
,→ tiempo de caída de un
,→ objeto."); System.out.print("Por favor,
System.out.print("Por favor, ,→ introduzca la primera nota: ");
,→ introduzca la altura (en Double nota1 = Double.parseDoubl c
,→ metros) desde la que cae el ,→ e(System.console().readLine());
,→ objeto: ");
Double h = Double.parseDouble(Sys c System.out.print("Ahora introduzca
,→ tem.console().readLine()); ,→ la segunda nota: ");
Double nota2 = Double.parseDoubl c
double s = Math.sqrt(2*h/g); ,→ e(System.console().readLine());

System.out.printf("El objeto tarda System.out.print("Por último


,→ %.2f segundos en caer.\n", s); ,→ introduzca la tercera nota: ");
// TODO code application logic Double nota3 = Double.parseDoubl c
,→ here ,→ e(System.console().readLine());
}
double media = (nota1 + nota2 +
} ,→ nota3) / 3;

System.out.printf("La media es
,→ %.2f\n", media);
// TODO code application logic
,→ here
}

7
Ingeniería Mecatrónica

lista de elementos
EJERCICIO 23
/*
* 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 ejercicio23;

/**
*
* @author Dell
*/
public class Ejercicio23 {

/**
* @param args the command line
,→ arguments
*/
public static void main(String[] args)
,→ {
double x1, x2;

System.out.println("Este programa
,→ resuelve ecuaciones de
,→ segundo grado.");
System.out.println("ax^2 + bx + c =
,→ 0");

System.out.println("Por favor,
,→ introduzca los valores.");

System.out.print("a = ");
double a = Double.parseDouble(Sys c
,→ tem.console().readLine());

System.out.print("b = ");
double b = Double.parseDouble(Sys c
,→ tem.console().readLine());

System.out.print("c = ");
double c = Double.parseDouble(Sys c
,→ tem.console().readLine());

// 0x^2 + 0x + 0 = 0

if ((a == 0) && (b == 0) && (c == 0)) {


System.out.println("La ecuación
,→ tiene infinitas soluciones.");
}

// 0x^2 + 0x + c = 0 con c distinto


,→ de 0

if ((a == 0) && (b == 0) && (c != 0)) {


System.out.println("La ecuación no
,→ tiene solución.");
}

// ax^2 + bx + 0 = 0 con a y b
,→ distintos de 0

if ((a != 0) && (b != 0) && (c == 0)) {


System.out.println("x1 = 0");
System.out.println("x2 = " + (-b / a));
}

8
// 0x^2 + bx + c = 0 con b y c
,→ distintos de 0

Вам также может понравиться