How do I get the percentage amount in this formula

I am trying to create a program that can calculate the same cargo bonus formula for my game i'm making, but i'm having a slight problem with this formula. I should be getting 40 at the end of the calculation but i just get 4.

The programmer said this about the formula:

For example: cargo value $100 and Same cargo multiplier is 2%
If you load 1 cargo then no bonus would be applied.

If you laod ie. 5 the same cargos bonus would be applied 4 times.

So final formula is $500 (for 5 cargos) + 8% x $500 = $500 + $40
X - cargo amount
Y - cargo value
Z - same cargo multiplier

X*Y + ((X-1)*Z)*Y = final value

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
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
#include <iostream>

using namespace std;

void SameCargoBonus();
void CargoDistanceBonusFrequency();

int main()
{
    cout << "Choose and option\n" << endl;

    cout << "1) Same Cargo Bonus Test" << endl;
    cout << "2) Cargo Distance Bonus Frequency" << endl;

    int choice;

    cin >> choice;

    switch(choice)
    {
        case 1:
            SameCargoBonus();
            break;
        case 2:
            CargoDistanceBonusFrequency();
            break;
        default:
            cout << "Error, something went wrong." << endl;
    }

    return 0;
}

void SameCargoBonus()
{
    cout << "Cargo Value" << endl;

    int cargoValue;

    cin >> cargoValue;

    cout << "\nAmount of cargo" << endl;

    int cargoAmount;

    cin >> cargoAmount;

    cout << "\nPercentage of value" << endl;

    int percentage;

    cin >> percentage;

    int sum = cargoAmount * cargoValue % percentage;

    cout << "\n" << sum << endl;
}

void CargoDistanceBonusFrequency()
{

}
Last edited on
The percentage sign basically tells you to devide by 100:

$500 (for 5 cargos) + (8/100) x $500 = $500 + $40
Topic archived. No new replies allowed.