0
Need assistance with the ticket office Quiz...
Here is My Code it works fine in the PC, I need assistance! #include <iostream> using namespace std; int main(){ int ages[5]; int elementsInArray = sizeof(ages)/sizeof(ages[0]); double totalPercentage = 100.0; double totalCosts = 50; int smallest = ages[0]; for(int i = 0; i < 5; ++i) { cin >> ages[i]; } for(int i = 0; i < elementsInArray; ++i) { if (ages[i] < smallest) { smallest = ages[i]; } } double costsAfterDiscount = totalCosts * ((totalPercentage - smallest)/totalPercentage); cout << smallest << endl; cout << "This is the amount you will have to pay:
quot; << costsAfterDiscount << endl; return 0; }4 Respostas
+ 1
Maleza Israel
You just need to do
double costAfterDiscount = 50.0 - 50.0 * smallest / 100;
0
Yes, initially I did that but the output in Sololearn App keeps on coming to 49, while trying to debug using the pc the program works well
0
int smallest = ages[0];
the assignment needs to go after the input loop but before the " find smallest" loop.
0
Thanks to you all; Pąľľąvī, RodwynneJonnes all of your assistance yielded great fruits, The bug was: I was to place the assignment after the loop!!!, Thanks again.
It WORKS!!!