Q:

How to do calculations price calculation based on time and wage

I am trying to figure out final price based on wage multiplied by hours.
Here is my code
Why if the hours are 02:30:00 and the wage: $14 is my total 2?
TimeSpan duration = TimeSpan.Parse("02:30:00"); 
int wage = 14;
var result = (duration.Hours + (duration.Minutes / 60) * wage);

A:

First, the expression is actually evaluated as:
duration.Hours + ((duration.Minutes / 60) * cleaner.Price)

Second, you are doing integer division, so 30/60 will result in 0, leaving you with the value 2 i.e. the Hours part.
To fix the issue, you can do something like the below:
(duration.Hours + ((decimal)duration.Minutes / 60)) * 14;

Alternatively, you can skip this component-wise calculation, and just use the TotalHours property instead:
duration.TotalHours * 14

