Docsity
Docsity

Prepara tus exámenes
Prepara tus exámenes

Prepara tus exámenes y mejora tus resultados gracias a la gran cantidad de recursos disponibles en Docsity


Consigue puntos base para descargar
Consigue puntos base para descargar

Gana puntos ayudando a otros estudiantes o consíguelos activando un Plan Premium


Orientación Universidad
Orientación Universidad


Ejercicios de Algoritmia y Programación: Semana 4, Ejercicios de Matemáticas

Algoritmia y Programacion de la universidad

Tipo: Ejercicios

2021/2022

Subido el 12/05/2022

winchester-japanese
winchester-japanese 🇵🇪

5

(1)

1 / 21

Toggle sidebar

Esta página no es visible en la vista previa

¡No te pierdas las partes importantes!

bg1
INGENIERIA DE
COMPUTACIÓN Y SISTEMAS
CURSO: ALGORITMIA Y PROGRAMACION - T1 - Nrc
2781
TIPO DE GRUPO: LABORATORIO
HORARIO: MIERCOLES (08:50 – 10:35 | 18:00 – 21:35)
NOMBRE DEL DOCENTE: CARLOS ALBERTO GAYTAN
TOLEDO
ALUMNO: PIERO ALEXANDER HUIMAN PAREDES
TITULO: TRABAJO DE LABORATORIO SEMANA 4
FECHA: 11 DE MAYO DE 2022
pf3
pf4
pf5
pf8
pf9
pfa
pfd
pfe
pff
pf12
pf13
pf14
pf15

Vista previa parcial del texto

¡Descarga Ejercicios de Algoritmia y Programación: Semana 4 y más Ejercicios en PDF de Matemáticas solo en Docsity!

INGENIERIA DE

COMPUTACIÓN Y SISTEMAS

CURSO: ALGORITMIA Y PROGRAMACION - T1 - Nrc

TIPO DE GRUPO: LABORATORIO

HORARIO: MIERCOLES (08:50 – 10:35 | 18:00 – 21:35)

NOMBRE DEL DOCENTE: CARLOS ALBERTO GAYTAN

TOLEDO

ALUMNO: PIERO ALEXANDER HUIMAN PAREDES

TITULO: TRABAJO DE LABORATORIO SEMANA 4

FECHA: 11 DE MAYO DE 2022

TRABAJO Nº 1

ALGORITMOS SECUENCIALES I

  1. Determinar si un alumno aprueba a reprueba un curso, sabiendo que aprobara si su promedio de tres calificaciones es mayor o igual a 11; reprueba en caso contrario.

ANÁLISIS: EFD

N1, N2, N3 (^) PROCESO Prom DISEÑO DEL ALGORITMO import java.io.*; public class ejer1tare {public static void main(String []args )throws IOException {BufferedReader br = new BufferedReader(new InputStreamReader(System.in)); int N1, N2, N3, Prom; System.out.print("\nIngrese primera calificacion:"); N1= Integer.parseInt (br.readLine()); System.out.print("\nIngrese segunda calificacion:"); N2= Integer.parseInt (br.readLine()); System.out.print("\nIngrese tercera calificacion:"); N3= Integer.parseInt (br.readLine()); Prom= ((N1+N2+N3)/3); if(Prom>=11) { System.out.println("\nEl alumno ha aprobado"); } else { System.out.println("\nEl alumno ha desaprobado"); } } } RESULTADO

  1. Ingrese tres números diferentes y luego imprímalos de tal modo que siempre estén en orden descendente.

ANÁLISIS: EFD

PROCESO

N1, N2, N3 Resultad

o

import java.io.*; public class ejer3tare {public static void main(String []args )throws IOException {BufferedReader br = new BufferedReader(new InputStreamReader(System.in)); int N1, N2, N3; System.out.print("Ingrese numero 1: "); N1 = Integer.parseInt(br.readLine()); System.out.print("Ingrese numero 2: "); N2 = Integer.parseInt(br.readLine()); System.out.print("Ingrese numero 3: "); N3 = Integer.parseInt(br.readLine()); if ((N1!=N2)&&(N1!=N3)&&(N2!=N3)) { if(N1>N2) { if(N1>N3) { if(N2>N3) { System.out.println("Orden descendente: " + N1 + " " + N2 + " " + N3); } else { System.out.println("Orden descendente: " + N2 + " " + N3 + " " + N1); } } else { System.out.println("Orden descendente: " + N3 + " " + N1 + " " + N2); } } else { if(N2>N3) { if(N1>N3) { System.out.println("Orden descendente: " + N2 + " " + N1 + " " + N3); } else { System.out.println("Orden descendente: " + N2 + " " + N3 + " " + N1); } } else { System.out.println("Orden descendente: " + N3 + " " + N2 + " " + N1); } } } else { System.out.println("\nError... Dato incorrecto"); } } }

DISEÑO DEL ALGORITMO RESULTADO

DISEÑO DEL ALGORITMO RESULTADO

  1. Calcular el total que una persona debe pagar en una librería, el precio de cada cuaderno es de S/ 9 si se compran menos de 10 cuadernos y de S/ 6 si se compran 10 o más.

ANÁLISIS: EFD

PROCESO

cant tot1,

tot

DISEÑO DEL ALGORITMO import java.io.; public class ejer5tare {public static void main(String []args )throws IOException {BufferedReader br = new BufferedReader(new InputStreamReader(System.in)); int cant, tot1, tot2; System.out.print("\nIngrese cuantos cuadernos quiere llevar:"); cant=Integer.parseInt(br.readLine()); if (cant<=0) { System.out.print("
nERROR....EL VALOR NO ES VÁLIDO"); } else { if (cant<10) { tot1=cant
9; System.out.print("\nLa cantidad a pagar es de:" +tot1); } if (cant>=10) { tot2=cant*6; System.out.print("\nLa cantidad a pagar es de:" +tot2); } } } RESULTADO

DISEÑO DEL ALGORITMO RESULTADO

  1. Una persona quiere comprar un televisor. Le ofrecen un televisor Led a P soles con X% de descuento y un televisor Plasma a Z soles con Y % de descuento. Cual debe comprar si desea pagar menos. Cuanto pagará en total.

ANÁLISIS: EFD

PROCESO

prec1,

DES1,

prec2, DES

Mensaje

import java.io.; public class ejer7tare {public static void main(String []args )throws IOException {BufferedReader br = new BufferedReader(new InputStreamReader(System.in)); int prec1, prec2; double DES1, DES2, Des1, Des2, tot1, tot2; System.out.print("\nIngrese el precio de la TV Led:"); prec1 = Integer.parseInt (br.readLine()); System.out.print("\nIngrese el descuento de la TV Led:"); DES1 = Integer.parseInt (br.readLine()); System.out.print("\nIngrese el precio de la TV Plasma:"); prec2 = Integer.parseInt (br.readLine()); System.out.print("\nIngrese el descuento de la TV Plasma:"); DES2 = Integer.parseInt (br.readLine()); Des1=(prec1(DES1/100)); tot1=prec1-Des1; Des2=(prec2*(DES2/100)); tot2=prec2-Des2; if (tot1==tot2) { System.out.print("\nLOS MONTOS SON IGUALES"); } else { if (tot1<tot2) { System.out.print("\nLa TV Led es más barata"); } else { System.out.print("\nLa TV Plasma es más barata"); } } } }

  1. Un obrero necesita calcular su salario semanal, el cual se obtiene de la siguiente manera: Si trabaja 40 horas o menos se le paga $16 por hora, Si trabaja mas de 40 horas se le paga $16 por cada una de las primeras 40 horas y $20 por cada hora extra.

ANÁLISIS: EFD

HT (^) PROCESO S1, ST DISEÑO DEL ALGORITMO import java.io.; public class ejer8tare {public static void main(String []args )throws IOException {BufferedReader br = new BufferedReader(new InputStreamReader(System.in)); int HT, SH, S1, S2, ST; System.out.print("\nIngrese las horas trabajadas:"); HT = Integer.parseInt (br.readLine()); if(HT<=40) { S1=HT16; System.out.print("\nSu salario semanal es de:" +S1); } if(HT>40) { S2=1640; ST=((HT- 40)20)+S2; System.out.print("\nSu salario semanal es de:" +ST); } } } RESULTADO

9. Diseñe un algoritmo que permita leer las longitudes de los tres lados de un triángulo (A, B y C)

y determinar qué tipo de triángulo es, de acuerdo a los siguientes casos. Suponiendo que A es el

mayor de los lados, y que B y C corresponden a los otros dos.

Si A = B + C No se forma un triángulo.

Si A 2 = B 2 + C 2 Se forma un triángulo rectángulo.

Si A 2 > B 2 + C 2 Se forma un triángulo obtusángulo

ANÁLISIS: EFD

PROCESO Tipo de

triangulo

L1, L2, L

DISEÑO DEL ALGORITMO DISEÑO DEL

if (C>A && C>B) { if (C==A+B) { System.out.print("\nNo se forma un triángulo"); } else {if ((CC)==(AA)+(BB)) { System.out.print("\nSe forma un triángulo rectángulo"); } else {if ((CC)>(AA)+(BB)) { System.out.print("\nSe forma un triángulo obtusángulo"); } } } } } } } RESULTADO

  1. Diseñe un algoritmo que permita leer 2 números enteros positivos N1, N2 y un operador artimético (+, -, , /, %) y realice las operación aritmética que corresponda y reporte la respuesta. (suma=N1+N2 , resta= N1-N2, producto= N1N2, cociente=N1/N2 , Residuo = N1%N2)

ANÁLISIS: EFD

PROCESO

N1, N2, OP s, r, p, c, re

import java.io.; public class ejer10tare {public static void main(String []args )throws IOException {BufferedReader br = new BufferedReader(new InputStreamReader(System.in)); int N1, N2, s, r, p; char OP; double c, re; System.out.print("\nIngrese primer número:"); N1= Integer.parseInt (br.readLine()); System.out.print("\nIngrese segundo número:"); N2= Integer.parseInt (br.readLine()); System.out.print("\nIngrese operador lógico:"); OP= br.readLine().toUpperCase().charAt(0); if ((OP=='+'||OP=='-'||OP==''||OP=='/'||OP=='%')) { if (OP=='+') { s=N1+N2; System.out.print("\nSu suma es: "+s); } if (OP=='-') { r=N1-N2; System.out.print("\nSu resta es: "+r); } if (OP=='') { p=N1N2; System.out.print("\nSu producto es es: "+p); } if (OP=='/') { c=N1/N2; System.out.print("\nSu cociente es: "+c); } if (OP=='%') { re=N1%N2; System.out.print("\nSu residuo es: "+re); } } else { System.out.print("\nError... Dato incorrecto"); } } }

  1. Un hombre desea saber cuánto dinero se genera por concepto de intereses con la cantidad que tiene depositada en el banco. El decidirá reinvertir los intereses solo si superan a $1000, y en ese caso desea saber cuánto dinero tendrá finalmente en su cuenta. Ingrese cantidad de dinero depositada y porcentaje de interés que le paga el banco. Debe reportar si decide reinvertir los intereses o No. Y cuanto dinero tendrá en su cuenta en total.

ANÁLISIS: EFD

PROCESO

Dep, Int DT, GAN

import java.io.; public class ejer11tare { public static void main(String [ ]args )throws IOException {BufferedReader in = new BufferedReader(new InputStreamReader(System.in)); double GAN,Int,Dep,DT; System.out.print("\nIngrese dinero depositado:"); Dep= Double.parseDouble(in.readLine()); System.out.print("\nIngrese el interés que le paga el banco:"); Int= Double.parseDouble(in.readLine()); GAN=(DepInt)/100; if(GAN>1000) { DT=Dep+GAN; System.out.println("El total de dinero en la cuenta es S/"+DT+ " y su ganancia por los intereses es S/"+GAN+ ", convendría reinvertir."); } else { DT=Dep+GAN; System.out.println("El total de dinero en la cuenta es S/"+DT+ " y su ganancia por los intereses es S/"+GAN+ ", no convendría reinvertir."); } DISEÑO DEL ALGORITMO RESULTADO

  1. Una agencia de autos necesita un sistema que le permita calcular el pago mensual para un vendedor de autos, basándose en lo siguiente: El pago base es de S/.1000, más una comisión de S/.150 por cada auto vendido y un bono adicional de S/.400 si vendió más de 10 autos. El impuesto a pagar es el 5 % del pago total. Ingresar el nombre del vendedor y el n° de autos vendidos en el mes. Reportar nombre del vendedor, sueldo bruto, impuesto y sueldo neto.

ANÁLISIS: EFD

PROCESO Nom, Cant, TOT, IMP,

ITot

NOM, Cant import java.io.*; public class ejer12tare { public static void main(String [] args) throws IOException { BufferedReader br = new BufferedReader(new InputStreamReader(System.in)); Double Cant, PB, COMI, BON, IMP, ITot, TOT; String NOM; System.out.print("\nIngresar su nombre: "); NOM = br.readLine().toUpperCase(); System.out.print("Ingresar cantidad de autos vendidos en el mes: "); Cant = Double.parseDouble(br.readLine()); if(Cant > 0) { if(Cant <= 9) { PB = Cant * 1000; COMI = Cant * 150; TOT = PB + COMI; IMP = TOT * 0.05; ITot = TOT - IMP; System.out.println("\n\t" + NOM); System.out.println("\tCantidad de autos vendidos: " + Cant); System.out.println("\tSueldo bruto:" + TOT); System.out.println("\tImpuesto de 5%:" +IMP); System.out.println("\tSueldo neto:" + ITot); } else { if (Cant >= 10) { PB = Cant * 1000; COMI = Cant * 150; BON = 400.0; TOT = PB + COMI + BON; IMP = TOT * 0.05; ITot = TOT - IMP; System.out.println("\n\t" + NOM); System.out.println("\tCantidad de autos vendidos: " + Cant); System.out.println("\tSueldo bruto:" + TOT); System.out.println("\tImpuesto de 5%:" +IMP); System.out.println("\tSueldo neto:" + ITot); } } } else { System.out.println("\nERROR...UNO O MAS DATOS NO SON VALIDOS"); } } }