Problem Statement
*** You may only submit a given problem once - no resubmissions will be accepted. ***
Salesmen and saleswomen often work for a commission. In other words, they get to keep a certain percentage of the sales they make. You have a saleswoman working for you who gets a whopping 20% commission, which cuts deep into your profit margins. You are considering replacing her with a cheaper salesman who will keep commission% of his sales. Out of each sale, cost% of the sale goes towards the cost of your products and other overhead. Your current saleswoman sells $sales of products a year. Your task is to determine how much the potential salesman would have to sell in a year to make you the same profit.?
Salesmen and saleswomen often work for a commission. In other words, they get to keep a certain percentage of the sales they make. You have a saleswoman working for you who gets a whopping 20% commission, which cuts deep into your profit margins. You are considering replacing her with a cheaper salesman who will keep commission% of his sales. Out of each sale, cost% of the sale goes towards the cost of your products and other overhead. Your current saleswoman sells $sales of products a year. Your task is to determine how much the potential salesman would have to sell in a year to make you the same profit.?
Definition
- Class:
- Commission
- Method:
- equivalentSales
- Parameters:
- double, double, double
- Returns:
- double
- Method signature:
- double equivalentSales(double sales, double cost, double commission)
- (be sure your method is public)
Notes
- Your result must have relative or absolute error of less than 1e-9.
- The commission is based on the gross sale, not the part of the sale that is above and beyond the cost. Therefore, if sales were $1000, your current saleswoman's commission would be $200.
- Note that neither sales nor the return value need to be in whole cents.
Constraints
- sales will be between 1 and 1e10, inclusive.
- cost will be between 0.5 and 79.5, inclusive.
- commission will be between 0.5 and 19.5, inclusive.
Examples
100.555
70.0
10.0
Returns: 50.2775
If you hire the new salesman, your profit margin will double from 10% to 20%. Thus, in order to make the same profits, he needs only sell half as much.756840
74.3
11.5
Returns: 303801.971830986
Your profit from your current saleswoman is $43139.88. If the potential salesman sells a little over $303801.97, your profit will also be the same.10000000000
79.5
19.5
Returns: 5.0E9
Note that the exact answer is $5E9, but a return of $4.999999999999823E9, for example, has an error of $0.000177 which is a relative error of much less than 1e-9.