homework 2. find total cost given all parameters