+ 1

# Hola, ¿pueden ayudarme con el ejercicio del examen del módulo 3 (C++)? // hello, can you help me with this exercise (C++)?

Me gustaría que me dijera cuál es mi error porque yo no logro verlo. Muchas gracias // I would like you to tell me what is my mistake, because I can't see it. Thank you very much.

6th Mar 2022, 8:10 PM
Eva
+ 1
#include <iostream> using namespace std; int main() { int ages[5]; float menor = 0; int entrada = 50; float descuento = 0; float total = 0; for (int i = 0; i < 5; ++i) { cin >> ages[i]; //tu código va aquí } if (ages[0] < ages[1]) { menor = ages[0]; } else { menor = ages[1]; } if (ages[2] < menor) { menor = ages[2]; } if (ages[3] < menor) { menor = ages[3]; } if (ages[4] < menor) { menor = ages[4]; } descuento = entrada * menor / 100; total = entrada - descuento; cout << total << endl; return 0; }
6th Mar 2022, 8:23 PM
Arsenii Hlazov
+ 1
pensar en la entrada: 2 3 1 4 5 minero = 1 pero lo obtienes como 2 Reconsidera tu lógica.. think about input : 2 3 1 4 5 miner = 1 but you getting it as 2 Rethink about your logic..
6th Mar 2022, 8:22 PM
Jayakrishna 🇮🇳
+ 1
This should work as intended.
6th Mar 2022, 8:24 PM
Arsenii Hlazov
+ 1
Thank you both very much
7th Mar 2022, 1:42 PM
Eva
0
Este es el código que yo hice. En la solución, me aparece que resuelve los tres primeros proyectos pero los otros dos aparece como error #include <iostream> using namespace std; int main() { int ages[5]; float menor = 0; int entrada = 50; float descuento = 0; float total = 0; for (int i = 0; i < 5; ++i) { cin >> ages[i]; //tu código va aquí } if (ages [0] < ages[1]) { menor = ages[0]; } else if (ages [1] < ages[2]) { menor = ages[1]; } else if (ages[2] < ages[3]) { menor = ages[3]; } else if (ages[3] < ages[4]) { menor = ages[3]; } else { menor = ages[4]; } descuento = entrada * menor / 100; total = entrada - descuento; cout << total << endl; return 0; }
6th Mar 2022, 8:12 PM
Eva
0
This is the code that I made. In the solution, it appears to me that it solves the first three projects but the other two appear as an error
6th Mar 2022, 8:13 PM
Eva
0
La consigna es: Estás trabajando en un sistema de tickets. Un ticket cuesta 10 dólares. La oficina está llevando a cabo una campaña de descuentos: cada grupo de 5 personas recibe un descuento, que se determina en función de la edad de la persona más joven del grupo. Necesitas crear un programa que tome las edades de las 5 personas como entrada y genere el precio total de los tickets. Ejemplo de entrada: 55 28 15 38 63 Ejemplo de salida: 42.5 La edad más joven es de 15 años, así que el grupo obtiene un 15% de descuento del precio total, que es \$50 - 15% = \$42.5 _____
6th Mar 2022, 8:15 PM
Eva
0
The problem is: You are working on a ticket system. A ticket costs 10 dollars. The office is running a discount campaign: each group of 5 people receives a discount, which is determined based on the age of the youngest person in the group. You need to create a schedule that takes the ages of all 5 people as input and outputs the total price of the tickets. Input example: 55 28 fifteen 38 63 Output example: 42.5 The youngest age is 15, so the group gets a 15% discount off the total price, which is \$50 - 15% = \$42.5
6th Mar 2022, 8:15 PM
Eva
0
//Just for your understandings, If you use a loop then you can simplify it more like : #include <iostream> using namespace std; int main() { int ages[5], entrada = 50; float menor = 0, descuento = 0,total = 0; for (int i = 0; i < 5; ++i) { cin >> ages[i]; } menor = ages[0]; for (int i = 1; i < 5; ++i) if (ages[i] < menor) menor = ages[i]; descuento = entrada * menor / 100; total = entrada - descuento; cout << total << endl; return 0; } //Hope it helps. //you're welcome.
7th Mar 2022, 1:57 PM
Jayakrishna 🇮🇳