+ 2

Why can't I find the error?? Plz help me to find the error.

You need to make a shipping cost calculator based on the order amount. The store uses the following cost structure: For orders in the US: - $75+ orders have free shipping - orders less than $75 have a shipping fee of 10% of the total order amount. For international orders, there is a 15% shipping fee, with a maximum of $50. This means that the maximum shipping fee for an international order is $50. You need to complete the given shippingCost() function, which takes the order amount and a Boolean indicating whether the order is international or not, and returns the shipping cost for that order. The return amount should be a Double. The function : 👇👇 if(international == true){ var cost:Double = amount*(15/100) if(cost > 50){ return 50.0 } return cost }else{ var cost:Double = amount*(10/100) if(cost > 75){ return 0.0 } return cost } } Why it showing only 0.0 and how can i solve this??

1st May 2021, 12:23 AM
Jawad Ibrahim Shopnil
Jawad Ibrahim Shopnil - avatar
3 Answers
+ 2
Hey Jawad Shopnil If you divide 15/100 or 10/100 it will produce 0 , so your overall answer will be zero !
1st May 2021, 12:36 AM
Giriraj Yalpalwar
Giriraj Yalpalwar - avatar
+ 1
Thirt13n Solve the program plzz.
1st May 2021, 8:00 AM
Jawad Ibrahim Shopnil
Jawad Ibrahim Shopnil - avatar
0
Hey Jawad Shopnil I don't know java but I can help you with this , if you understand this thats good ! If some error occurs you can tell me or debug yourself ! if you have test cases then you can send me ! if (international==true) { Shipping=((amount*15)/100)+((amount%15)/10) if(shipping>50) return 50 else return shipping } else { if(amount>75) return 0.0 else { return ((amount*10)/100)+((amount%10)/10) } }
1st May 2021, 12:42 PM
Giriraj Yalpalwar
Giriraj Yalpalwar - avatar