Created
May 28, 2021 19:27
-
-
Save Abiola-Farounbi/bf554d4dcd8cf30fc6d780f056e50f9d to your computer and use it in GitHub Desktop.
In this problem set, i was able to handle how to output a decimal in c++
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// Sololearn problem set for c++ | |
// You are working on a ticketing system. A ticket costs $10. | |
// The office is running a discount campaign: each group of 5 people is getting a discount, which is determined by the age of the youngest person in the group. | |
// You need to create a program that takes the ages of all 5 people as input and outputs the total price of the tickets. | |
// Sample Input: 55 28 15 38 63 | |
// Sample Output: 42.5 | |
// The youngest age is 15, so the group gets a 15% discount from the total price, which is $50 - 15% = $42.5 | |
#include <iostream> | |
using namespace std; | |
int main() { | |
int ages[5]; | |
for (int i = 0; i < 5; ++i) { | |
cin >> ages[i]; | |
} | |
//your code goes here | |
int min ; | |
min = ages[0]; | |
for (int x = 0; x < 5; x++){ | |
if( ages[x] < min){ | |
min = ages[x]; | |
} | |
} | |
// TO OUTPUT OUT DECIMALS USE (FLOAT) | |
float percent =( (float) ( 50 * min ) / 100) ; | |
cout << 50 - percent << endl; | |
return 0; | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment