0% encontró este documento útil (0 votos)
17 vistas19 páginas

Programación Java y Python: Ejercicios

Ejercicios de pseudocódigo

Cargado por

Ashley Arumy
Derechos de autor
© © All Rights Reserved
Nos tomamos en serio los derechos de los contenidos. Si sospechas que se trata de tu contenido, reclámalo aquí.
Formatos disponibles
Descarga como PDF, TXT o lee en línea desde Scribd
0% encontró este documento útil (0 votos)
17 vistas19 páginas

Programación Java y Python: Ejercicios

Ejercicios de pseudocódigo

Cargado por

Ashley Arumy
Derechos de autor
© © All Rights Reserved
Nos tomamos en serio los derechos de los contenidos. Si sospechas que se trata de tu contenido, reclámalo aquí.
Formatos disponibles
Descarga como PDF, TXT o lee en línea desde Scribd

A) Instala y configura software para entorno de trabajo.

Evidencia de capturas de pantalla de


instalación correcta del Java en el entorno de edición como es la aplicación Visual Studio
Code donde se observe un código de programa escrito en Java y también la ejecución de este.

1. Instalación de JAVA.

2. Instalación de PYTHON.
B) Crear un programa en Java y Python con 9 expresiones algebraicas de ejercicios nones
tomadas de la Imagen de expresiones Algebraicas que está en los recursos de este tema
(ejercicio 11) y convertirlas a expresiones del lenguaje de Java y Python, representarlos en el
programa, substituyendo los valores de las variables como se indica en la figura y ejercicios
en y obtener su resultado, mostrando esta ejecución del programa de cada ejercicio. El código
de este programa y ejecución, deberán ser integrados. La precedencia de los operadores
es esencial para aplicarlos en cada una de las expresiones de java, para que el resultado sea
el desea y correcto.

1) PYTHON (Código de ejecución).


import math
print("ejercio 1")
a = int(input("Ingrese A: "))
b= int(input("Ingrese B: "))
oper= 5*a*b
print("Resultado: ", oper)
print("-------------------------------------------------------------")
print("ejercio 3")
b=int(input("Ingrese B: "))
m=float(input("Ingrese M: "))
n=float(input("Ingrese N: "))
oper=((b**2)*m*n)
print("Resultado: ", oper)
print("-------------------------------------------------------------")
print("ejercio 5")
a=int(input("Ingrese A: "))
b=int(input("Ingrese B: "))
m=float(input("Ingrese M: "))
oper=((2/3)*(a**4)*(b**2)*(m**3))
print("Resultado: ", oper)
print("-------------------------------------------------------------")
print("ejercio 7")
b=int(input("Ingrese B: "))
c=int(input("ingresa C: "))
m=float(input("Ingrese M: "))
n=float(input("Ingrese N: "))
p=float(input("Ingrese P: "))
oper=((m**b)*(n**c)*(p**2))
print("Resultado: ", oper)
print("-------------------------------------------------------------")
print("ejercio 9")
b=int(input("Ingrese B: "))
c=int(input("ingresa C: "))
oper=2*b*(c**2)
ref=(oper**0.5)
print("Resultado: ",ref )
print("-------------------------------------------------------------")
print("ejercio 11")
a=int(input("Ingrese A: "))
b=int(input("ingresa B: "))
m=float(input("ingresa M: "))
n=float(input("ingresa N: "))
oper=m*n
oper2=(8*(a**4)*(b**3))
ref=(oper*(oper2**0.5))
print("Resultado: ",ref )
print("-------------------------------------------------------------")
print("ejercio 13")
a=int(input("Ingrese A: "))
m=float(input("ingresa M: "))
n=float(input("ingresa N: "))
p=float(input("ingresa P: "))
oper=(5*(b**2)*(m**2))
oper2=n*p
ref=(oper/oper2)
print("Resultado: ",ref )
print("-------------------------------------------------------------")
print("ejercio 15")
m=float(input("ingresa M: "))
n=float(input("ingresa N: "))
oper=2*m
oper2=((n**2)**0.5)
ref=(oper/oper2)
print("Resultado: ",ref )
print("-------------------------------------------------------------")
print("ejercio 17")
b=int(input("Ingrese B: "))
c=int(input("ingresa C: "))
m=float(input("Ingrsa M: "))
ra=64*(b**3)*(c**6)
raiz=math.pow(ra,1/3)
oper=3*raiz
oper2=2*m
ref=(oper/oper2)
resff=round(ref)
print("Resultado: ",resff )
print("-------------------------------------------------------------")
1.1) Resultados de la Ejecución (PYTHON).
2) JAVA (Código de ejecución).
import java.util.Scanner;

public class tarea {


public static void main(String[] args) {
Scanner scanner = new Scanner(System.in);

System.out.println("ejercio 1");
System.out.print("Ingrese A: ");
int a = scanner.nextInt();
System.out.print("Ingrese B: ");
int b = scanner.nextInt();
double oper = 5 * a * b;
System.out.println("Resultado: " + oper);
System.out.println("-------------------------------------------------------------");

System.out.println("ejercio 3");
System.out.print("Ingrese B: ");
b = scanner.nextInt();
System.out.print("Ingrese M: ");
double m = scanner.nextDouble();
System.out.print("Ingrese N: ");
double n = scanner.nextDouble();
oper = (double) ((Math.pow(b, 2) * m * n));
System.out.println("Resultado: " + oper);
System.out.println("-------------------------------------------------------------");

System.out.println("ejercio 5");
System.out.print("Ingrese A: ");
a = scanner.nextInt();
System.out.print("Ingrese B: ");
b = scanner.nextInt();
System.out.print("Ingrese M: ");
m = scanner.nextDouble();
oper = (double) ((2.0 / 3) * (Math.pow(a, 4)) * (Math.pow(b, 2)) * (Math.pow(m, 3)));
System.out.println("Resultado: " + oper);
System.out.println("-------------------------------------------------------------");

System.out.println("ejercio 7");
System.out.print("Ingrese B: ");
b = scanner.nextInt();
System.out.print("ingresa C: ");
int c = scanner.nextInt();
System.out.print("Ingrese M: ");
m = scanner.nextDouble();
System.out.print("Ingrese N: ");
n = scanner.nextDouble();
System.out.print("Ingrese P: ");
double p = scanner.nextDouble();
oper = (double) ((Math.pow(m, b)) * (Math.pow(n, c)) * (Math.pow(p, 2)));
System.out.println("Resultado: " + oper);
System.out.println("-------------------------------------------------------------");

System.out.println("ejercio 9");
System.out.print("Ingrese B: ");
b = scanner.nextInt();
System.out.print("ingresa C: ");
c = scanner.nextInt();
oper = 2 * b * (int) (Math.pow(c, 2));
double ref = Math.sqrt(oper);
System.out.println("Resultado: " + ref);
System.out.println("-------------------------------------------------------------");

System.out.println("ejercio 11");
System.out.print("Ingrese A: ");
a = scanner.nextInt();
System.out.print("ingresa B: ");
b = scanner.nextInt();
System.out.print("ingresa M: ");
m = scanner.nextDouble();
System.out.print("ingresa N: ");
n = scanner.nextDouble();
oper = (double) (m * n);
double oper2 = 8 * (Math.pow(a, 4)) * (Math.pow(b, 3));
ref = oper * Math.sqrt(oper2);
System.out.println("Resultado: " + ref);
System.out.println("-------------------------------------------------------------");

System.out.println("ejercio 13");
System.out.print("Ingrese A: ");
a = scanner.nextInt();
System.out.print("ingresa M: ");
m = scanner.nextDouble();
System.out.print("ingresa N: ");
n = scanner.nextDouble();
System.out.print("ingresa P: ");
p = scanner.nextDouble();
oper = (double) (5 * (Math.pow(b, 2)) * (Math.pow(m, 2)));
oper2 = n * p;
ref = oper / oper2;
System.out.println("Resultado: " + ref);
System.out.println("-------------------------------------------------------------");

System.out.println("ejercio 15");
System.out.print("ingresa M: ");
m = scanner.nextDouble();
System.out.print("ingresa N: ");
n = scanner.nextDouble();
oper = 2 * (double) m;
oper2 = Math.sqrt(Math.pow(n, 2));
ref = oper / oper2;
System.out.println("Resultado: " + ref);
System.out.println("-------------------------------------------------------------");

System.out.println("ejercio 17");
System.out.print("Ingrese B: ");
b = scanner.nextInt();
System.out.print("ingresa C: ");
c = scanner.nextInt();
System.out.print("Ingrsa M: ");
m = scanner.nextDouble();
double ra = 64 * (Math.pow(b, 3)) * (Math.pow(c, 6));
double raiz = Math.pow(ra, 1.0 / 3);
oper = (double) (3 * raiz);
oper2 = 2 * (double) m;
ref = oper / oper2;
double resff = (double) Math.round(ref);
System.out.println("Resultado: " + resff);
System.out.println("-------------------------------------------------------------");
}
}
2.1) Resultados de la Ejecución (JAVA).
C) Hacer un programa en Java y en Python donde se utilicen todos los operadores: aritméticos,
de relación, lógicos, sobre bits, vistos en clase. Mostrar el uso de cada operador utilizando una
expresión donde se incluyan estos, mostrar el código y resultados y anexar dentro del mismo
documento, código y ejecución.

1) PYTHON (Operadores diversos).


# Operadores aritméticos en Python
a = 20
b = 15

# Suma
suma = a + b
print("Suma:", suma)

# Resta
resta = a - b
print("Resta:", resta)

# Multiplicación
multiplicacion = a * b
print("Multiplicación:", multiplicacion)

# División
division = a / b
print("División:", division)

# División entera
division_entera = a // b
print("División entera:", division_entera)

# Módulo (resto de la división)


modulo = a % b
print("Módulo:", modulo)

# Exponente
exponente = a ** b
print("Exponente:", exponente)

# Ejemplo de operadores de relación y lógicos en Python

# Operadores de relación
igual = a == b
print(a," == ",b," ", igual)
no_igual = a != b
print("a != b:", no_igual)

mayor_que = a > b
print("a > b:", mayor_que)

menor_que = a < b
print("a < b:", menor_que)

mayor_o_igual = a >= b
print("a >= b:", mayor_o_igual)

menor_o_igual = a <= b
print("a <= b:", menor_o_igual)

# Operadores lógicos
x = True
y = False

and_logico = x and y
print("x and y:", and_logico)

or_logico = x or y
print("x or y:", or_logico)

not_logico_x = not x
print("not x:", not_logico_x)

not_logico_y = not y
print("not y:", not_logico_y)
1.1) Resultados de la Ejecución (PYTHON).
1) JAVA (Operadores diversos).

public class OA {

public static void main(String[] args) {


int a = 200;
int b = 600;
int r;
boolean bb;

// Operadores aritmeticos
r = a + b;
System.out.println(a + " + " + b + " = " + r);
r = a - b;
System.out.println(a + " - " + b + " = " + r);
r = a * b;
System.out.println(a + " x " + b + " = " + r);
r = a / b;
System.out.println(a + " / " + b + " = " + r);
r = a % 2;
System.out.println(a + " % " + 2 + " = " + r);

// operadores de relacion
bb = a > b;
System.out.println(a + " > " + b + " = " + bb);
bb = a < b;
System.out.println(a + " < " + b + " = " + bb);

// Operadores logicos
bb = a < b && b > a;
System.out.println(a + " < " + b + " && " + b + " > " + a + "=" + bb);
bb = a < b || b > a;
System.out.println(a + " < " + b + " || " + b + " > " + a + "=" + bb);

}
2.1) Resultados de la Ejecución (JAVA).
D) Realizar los programas en Java y en Python, mostrando código y la ejecución de los
siguientes tres ejercicios que se piden resolver, anexando captura de pantalla de cada uno.

• Problema 1: Solicitar al usuario una temperatura en grados Celsius y mostrar su


equivalente en grados Fahrenheit.
• Formula: F= 9/5*C*32

• Problema 2: Solicitar al usuario una distancia en kilómetros y mostrar su equivalente en


millas.
• Formula: Millas= Kilometros * 0.621371

• Problema 3: Solicitar al usuario un tiempo en minutos y mostrar su equivalente en horas y


minutos. Aquí se piden dos resultados, las Horas y los Minutos restantes.
• Fórmula: Horas=Minutos/60 y Minutos restantes=Minutos%60

1) PYTHON (Ejercicios).

print("Problema 1")
cel= float(input("Ingresa temperatura en grados Celsius; "))
fa=9/5*cel+32
print("los grados a Fahrenheit son: ",fa)
print("---------------------------------------------------")
print("Problema 2")
ki= float(input("Ingresa Los kilometros; "))
mi= ki*0.621371
print("la conversion de kilometros a millas es: ",mi)
print("---------------------------------------------------")
print("Problema 3")
min= float(input("Ingresa los minutos; "))
ho=min/60
mir=min % 60
hora=int(ho)
minutos=int(mir)
print("la conversion de minutos a horas es: ",hora,":",minutos)
1.1) Resultados de la Ejecución (PYTHON).
1) JAVA (Ejercicios).

import java.util.Scanner;

public class problemas {


public static void main(String[] args) {
Scanner scanner = new Scanner(System.in);

System.out.println("Problema 1");
System.out.print("Ingrese la temperetura en Celsius:");
double cel = scanner.nextInt();
double fa = (9.0 / 5) * cel + 32;
System.out.println("los grados a Fahrenheit son: " + fa);
System.out.println("---------------------------------------------------");

System.out.println("Problema 2");
System.out.print("Ingrese los Kilometros:");
double ki = scanner.nextInt();
double mi = ki * 0.621371;
System.out.println("la conversion de kilometros a millas es: " + mi);
System.out.println("---------------------------------------------------");

System.out.println("Problema 3");
System.out.print("Ingrese los Minutos:");
double min = scanner.nextInt();
double ho = min / 60;
double mir = min % 60;
int hora = (int) ho;
int minutos = (int) mir;
System.out.println("la conversion de minutos a horas es: " + hora + ":" + minutos);
}

private static String input(String string) {


// TODO Auto-generated method stub
throw new UnsupportedOperationException("Unimplemented method 'input'");
}
}
1.1) Resultados de la Ejecución (JAVA).

También podría gustarte