Help with tip splitting issue?

Hi guys, so I've designed a program to help me close the register at the end of the night. It works great except I have yet to implement the ability to determine how the credit card tips will be split via my program. (I work in a restaurant)I usually do it by hand by...

writing out the list of people who worked that day and how many hours they worked.

I then add their hours to get the total hours worked.

I then go to each employee on the list, divide their hours worked by total hours worked.

This provides me with the percentage amount that that employee gets of the total tips.

I do this for each employee and then multiply their percentages by the total tips in order to determine which person gets which amount of money. Should I create a loop that allows the user to create their chosen amount of "employee" classes and then the appropriate variables for each one? I'm worried about this because I'm not sure how to go about handling an unknown amount of classes as there are different amounts of employees that work each day. Any tips or advice?
Something like:
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
#include <iostream>
#include <numeric>
#include <vector>

using employee = std::pair<std::string, double>;

std::vector<employee> get_employees()
{
    std::vector<employee> result;
    std::string input;
    while(std::cin) {
        std::cout << "Enter employee name (q to quit)\n";
        std::getline(std::cin >> std::ws, input);
        if(input == "q") break;
        std::cout << "Enter employee hours\n";
        double d;
        std::cin >> d;
        result.emplace_back(input, d);
    }
    return result;
}

int main()
{
    std::cout << "Enter today tips: ";
    double tips;
    std::cin >> tips;
    auto employees = get_employees();
    double total_hours = std::accumulate(employees.begin(), employees.end(), 0.0,
                                                    [](double r, const employee& e)
                                                    {
                                                        return r + e.second;
                                                    });
    for(const auto& e: employees)
        std::cout << e.first << " earned " << tips * (e.second/total_hours) << '\n';
}
Enter today tips: 120
Enter employee name (q to quit)
Max
Enter employee hours
6
Enter employee name (q to quit)
Joan
Enter employee hours
6
Enter employee name (q to quit)
Harry
Enter employee hours
5
Enter employee name (q to quit)
Tom
Enter employee hours
3
Enter employee name (q to quit)
q
Max earned 36
Joan earned 36
Harry earned 30
Tom earned 18
Topic archived. No new replies allowed.