asp.net mvc - Calculate total cost based on rate and duration like Hours,Minutes with C# -


i have dropdown list present duration of specific job format "hours,minutes":

<select class="form-control">     <option></option>     <option>0,10</option>     <option>0,20</option>     <option>0,30</option>     <option>0,40</option>     <option>0,50</option>     <option>1</option>     <option>1,10</option>     <option>1,20</option>     <option>1,30</option>     <option>1,40</option>     <option>1,50</option> </select> 

i have rate hour:

var rate = "8"; // 8 € 

if user selects example "1,3", how can calculate total cost based on rate? (in case total 12€)

you can do

string[] time  = "1,30".split(",");  int total = convert.toint32(time[0]) * rate;  if (time.length >1)     total += convert.toint32(time[1]) * rate / 60; 

Comments

Popular posts from this blog

php - Wordpress website dashboard page or post editor content is not showing but front end data is showing properly -

javascript - Get parameter of GET request -

javascript - Twitter Bootstrap - how to add some more margin between tooltip popup and element -