- To learn more about types in Go, check Tour of Go: Basic Types.
- To learn more about type conversions in Go, check Tour of Go: Type Conversions.
- The percentage (passed as an argument) is a number between 0-100. To make this percentage a bit easier to work with, start by dividing it by 100.
- To compute the number of cars produced successfully, multiply the percentage (divided by 100) by the number of cars produced.
- When multiplying two numbers together, they both need to be of the same type. Use type conversions if needed.
- Start by calculating the production of successful cars per hour. For this, you can use the
CalculateProductionRatePerHour
function you made from the previous step. - Knowing the production per hour of cars, you can get the production per minute by dividing the production per hour by 60 (the number of minutes in an hour).
- Remember to cast the result to an
int
.
- Start by working out how many groups of 10 cars there are. You can do this by dividing the number of cars by 10.
- Then work out how many cars are remaining (the modulo operator is useful for this).
- To arrive at the cost, multiply the number of groups by the cost to produce 10 cars and then multiply the number of cars remaining by the cost to produce each individual car. Then sum the results of the multiplication together.