+ 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
9 Answers
+ 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
Arsenii Hlazov - avatar
+ 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
Arsenii Hlazov - avatar
+ 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 馃嚠馃嚦