Documentos de Académico
Documentos de Profesional
Documentos de Cultura
Taller 1 Corte
Taller 1 Corte
Taller 14-09-2020
Programación Orientada a Objetos -
POO
camilo andres belalcazar
package ejerciciou1y2;
ejercicio 3
package ejercicio.pkg3;
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
/** /**
* *
* @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
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
/** /**
* *
* @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
System.out.println(dia);
// TODO code application logic
,→ here
}
5
Ingeniería Mecatrónica
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
/** /**
* *
* @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("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
// ax^2 + bx + 0 = 0 con a y b
,→ distintos de 0
8
// 0x^2 + bx + c = 0 con b y c
,→ distintos de 0