+ 2

I dont get a Error

Did you get a Error ? I put a input but dont got a output…what you think whats my fault is ? https://code.sololearn.com/ceGOQZte8hUL/?ref=app

18th Aug 2021, 3:17 PM
Ilker Akkurt
3 Respostas
+ 6
Ilker Akkurt You have many mistakes 1 - totalPrice is local variable so you can't access directly in any other methods so pass it as a parameter. 2 - result will be double value not int so change int to double. 3 - you have return type int so cast double with int 4 - you have return value in if block only so what if block not execute then you will get error so return outside the condition also. 5 - no need to write else if condition, you can directly return totalPrice 6 - you didn't print returned value. So here is solution https://code.sololearn.com/c7FacVAa9qwI/?ref=app
18th Aug 2021, 4:11 PM
A͢J
A͢J - avatar
+ 7
<totalPrice> is local to Main(). It is not recognized by Discount(). In Discount() line 27, you tried to output <max> which is an undefined variable. In Discount, you return <result> at line 28, where <totalPrice> is greater than or equal to 10000. But for the opposite condition, you output <totalPrice> without returning anything. Depending on the task given, you should note whether to return something from Discount(), or to directly output something in there.
18th Aug 2021, 3:57 PM
Ipang
+ 2
Tyvm
18th Aug 2021, 4:27 PM
Ilker Akkurt