Help, Has the payment been accepted? Get and Set - If Else | Sololearn: Learn to code for FREE!
New course! Every coder should learn Generative AI!
Try a free lesson
0

Help, Has the payment been accepted? Get and Set - If Else

I need help with the output of the code in the If Else statement in the Set property. This is the description of the exercise: You are creating our payment request. The maximum payment you can make in one go is 50,000. The program that you are given takes the payment value as input. Populate the property provided to take the payment, assign it to the appropriate class member, and generate "Accepted" if the payment is not greater than 50000. If it is, the property should generate "Error." Input example 15000 Output example Accepted. Use the if else condition inside the set accessor to handle the check. https://code.sololearn.com/cnH7kGeXRRo1/?ref=app

27th Jun 2021, 12:44 PM
Alex Narváez
Alex Narváez - avatar
4 Answers
+ 4
Alex Narváez You missed to add this line in set before the if condition. paymentValue = value; Write before if condition ----------Setter---------- set { paymentValue = value; if(paymentValue <= 50000) { Console.Write("Accepted"); } else { Console.Write("Error"); } }
27th Jun 2021, 1:02 PM
A͢J
A͢J - avatar
+ 2
Alex Narváez paymentValue should be <= 50000 maximum payment is 50000 so it should be either less than or equal to 50000
27th Jun 2021, 12:54 PM
A͢J
A͢J - avatar
+ 2
Thank you very much for your answer, however I already changed it and the output error persists. There is something else wrong with the Set property in the If else statement
27th Jun 2021, 12:59 PM
Alex Narváez
Alex Narváez - avatar
+ 1
Excellent! thank you very much for your help. She had forgotten that detail. I appreciate your time and availability to help me. I am very grateful
27th Jun 2021, 1:08 PM
Alex Narváez
Alex Narváez - avatar