Calculate the Rounded Profit

Published by Matteo Matt in

You work for a manufacturer, and have been asked to calculate the total profit made on the sales of a product. You are given a starting inventory and a vector containing the cost price per unit (in dollars) and the sell price per unit (in dollars). Return the total profit made, rounded to the nearest dollar.

Examples

profit({32.67, 45.00}, 1200) ➞ 14796

profit({225.89, 550.00}, 100) ➞ 32411

profit({2.77, 7.95}, 8500) ➞ 44030

Notes

  • Assume all inventory has been sold.
Watch a quick demo on how Edabit works.