Data Journey

International Studies Grad. racing for AI Engineer

Download as .zip Download as .tar.gz View on GitHub
9 January 2021

Smallest Element: array

by mervyn

Discount Program

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

#include <iostream>
using namespace std;

int main() {
    int ages[5];
    int min = ages[0];
    double price;
    double dis;

    for (int i = 0; i < 5; ++i) {
        cin >> ages[i];
        if(min>ages[i])
        	min = ages[i];
    }

    dis = min*0.01;
    price= 10*5;

    price *= (1-dis);

	cout<<price<<endl;

    return 0;
}
    int *ages = NULL;
    ages = new int[5];
tags:

Comments

Post comment
Loading...

Share this: