Is the payment accepted? (help) | Sololearn: Learn to code for FREE!
New course! Every coder should learn Generative AI!
Try a free lesson
0

Is the payment accepted? (help)

You are creating our payment application. The maximum payment it can make at one time is 50000. The program you are given takes the payment value as input. Complete the provided property to take the payment, assign it to appropriate class member, and output "Accepted" if the payment isn't greater than 50000. If it is, the property should output "Error." I came up with this code:https://code.sololearn.com/cflQgrF503Lx problem is if I put the input more than 50000, it'll still write "Accepted", even though the if statement is there The solution that I found is to put the _payment = value; before the if else statement, but that would still change the variable even though I want the variable to not change if a statement isn't fulfilled Any clue?

31st Aug 2021, 12:54 PM
Vincent Xavery Harlim
Vincent Xavery Harlim - avatar
2 Answers
+ 2
Just re-read, if you don’t want to assign the value first you can always perform the comparison on ‘value’: set { if (value <= 50000) { _paymentValue = value; Console.WriteLine("Accepted"); }
3rd Sep 2021, 4:56 PM
DavX
DavX - avatar
0
You haven’t assigned the value of paymentValue in the setter: set { paymentValue = value; if ........
3rd Sep 2021, 4:47 PM
DavX
DavX - avatar