I have a tableView holding an array of 4 items:var frequency = [    Item(name:Every week,selected: false, amount: 0),    Item(name:Every 2 weeks,selected: false, amount: 0),    Item(name:Every 4 weeks,selected: false, amount: 0),    Item(name:Once,selected: false, amount: 0),    Item(name:End of tenancy cleaning, selected: false, amount: 0)]Every time a row is selected, the previous one is deselected, meaning that there will never be 2 rows selected at the same time.  Based on the selected row, I need to assign a value to:var numberHours = 0var price = 0I have tried doing this with if else statement but my code will become too verbose. There is a pattern for all cases in which selectedBed >=3.var selectedBed:Int! // receives value from another ViewControllervar selectedBath:Int! //  receives value from another ViewControllerI need to know if you have a better approach that would make my code less verbose.let rate1 = 14  let rate2 = 12let rate3 = 11let rate4 = 18var numberHours = 0var minHours = 2var price = 0var selectedBed:Int!var selectedBath:Int!Case 1.1if selectedBed <= 1 && selectedBath < 5 && frequency[indexPath.row] == 3 //     Once {    numberHours =  minHours        price = numberHours * rate1} else if selectedBed <= 1 && selectedBath < 5 && frequency[indexPath.row] ==     4 // end of tenancy {   numberHours = 5      price = 90        } else if selectedBed <= 1 && selectedBath < 5 && frequency[indexPath.row] =!     3 || 4 // Every week,Every 2 weeks,Every 4 weeks {      numberHours = minHours            price = numberHours * rate3 }Case 1.2// very unlikely to have 1 bed flat + 5 baths or more  if selectedBed <= 1 && selectedBath >= 5 && frequency[indexPath.row] == 3 {numberHours = 5     price = numberHours * rate2}   else if selectedBed <= 1 && selectedBath >= 5 && frequency[indexPath.row] ==    4     {  numberHours = 6    price =  numberHours * rate1} else if selectedBed <= 1 && selectedBath >= 5 && frequency[indexPath.row] =! 3  || 4 {  numberHours = 5       price = numberHours * rate1}Case 2. if selectedBed == 2 && selectedBath >= 0 && frequency[indexPath.row] == 3 {   numberHours = 3       price = numberHours * rate2    } else if selectedBed == 2 && selectedBath >= 0 &&     frequency[indexPath.row] == 4         numberHours = 7             price = numberHours * rate4                 } else if selectedBed == 2 && selectedBath >= 0 &&     frequency[indexPath.row] =! 3 || 4 {                      numberHours = 3                         price = numberHours * rate3}Case 3.1if selectedBed == 3 && selectedBath <= 2 && frequency[indexPath.row] == 3 { numberHours = 3    price = numberHours * rate2  } else if selectedBed == 3 && selectedBath <= 2 && frequency[indexPath.row] == 4 {         numberHours = 8            price = numberHours * rate4          } else if selectedBed == 3 && selectedBath <= 2 && frequency[indexPath.row] != 3 || 4 {               numberHours = 3                    price = numberHours * rate3 }Case 3.2if selectedBed == 3 && selectedBath >= 3 <= 6 && frequency[indexPath.row] == 3{numberHours = selectedBed + 1  price = numberHours * rate2  } else if     selectedBed == 3 && selectedBath >= 3 <= 6 && frequency[indexPath.row] == 4            numberHours = 9           price = numberHours * rate4          } else if selectedBed == 3 && selectedBath >= 3 <= 6  && frequency[indexPath.row] != 3 || 4 {              numberHours = selectedBed + 1                   price = numberHours * rate3                }  else if                       selectedBed == 3 && selectedBath >= 7 <= 8 && frequency[indexPath.row] == 3 {                        numberHours = selectedBed + 2                           price = numberHours * rate2     } else ifselectedBed == 3 && selectedBath >= 7 <= 8 && frequency[indexPath.row] == 4 {    numberHours = 10         price = numberHours * rate4} else if  selectedBed == 3 && selectedBath >= 7 <= 8 && frequency[indexPath.row]  != 3 || 4 {    numberHours = selectedBed + 2         price = numberHours * rate3    }   else if              selectedBed == 3 && selectedBath >= 9 <= 10 && frequency[indexPath.row] == 3 {                numberHours = selectedBed + 3                   price = numberHours * rate2    } else if        selectedBed == 3 && selectedBath >= 9 <= 10 && frequency[indexPath.row] == 4 {        numberHours = 11           price = numberHours * rate4       } else if               selectedBed == 3 && selectedBath >= 9 <= 10 &&     frequency[indexPath.row] != 3 || 4{                 numberHours = selectedBed + 3                    price = numberHours * rate3}1 bed + 1 bath = 2 hours   24 12/h    22 11/h1 bed + 2 bath = 3 hours   36/12    33/111 bed + 3 bath = 3 hours   36/12    33/111 bed + 4 bath = 3 hours   36/12    33/111 bed + 5 or n bath = 5 hours   60/12    55/112 bed + 0 or n bath = 3 hours   36/12    33/113 bed + 1 bath = 3 hours   36/12    33/113 bed + 2 bath = 3 hours   36/12    33/113 bed + 3 bath = 4 hours   48/12    44/11 3 bed + 4 bath = 4 hours   48/12    44/11 3 bed + 5 bath = 4 hours   48/12    44/11 3 bed + 6 bath = 4 hours   48/12    44/11 3 bed + 7 bath = 5 hours   60/12    55/11 3 bed + 8 bath = 5 hours   60/12    55/11  3 bed + 9 bath = 6 hours   72/12    66/113 bed + 10 bath = 6 hours   72/12    66/114 bed + 1 bath = 4 hours   48/12    44/114 bed + 2 bath = 4 hours   48/12    44/114 bed + 3 bath = 5 hours   60/12    55/11 4 bed + 4 bath = 5 hours   60/12    55/11  4 bed + 5 bath = 5 hours   60/12    55/11  4 bed + 6 bath = 5 hours   60/12    55/11  4 bed + 7 bath = 6 hours   72/12    66/11 4 bed + 8 bath = 6 hours   72/12    66/11 4 bed + 9 bath = 7 hours   84/12    77/114 bed + 10 bath = 7 hours   84/12    77/11
House cleaning calculator
swift;calculator