₦airaland Forum

Welcome, Guest: Register • Login • With Google • Trending • Recent • New

Stats: 3,344,623 members, 8,512,813 topics. Date: Wednesday, 04 November 2026 at 04:06 AM

Toggle theme

Please Help Out - Programming - Nairaland

Nairaland Forum › Science/Technology › Programming › Please Help Out (1034 Views)

1 Reply (Go Down)

Please Help Out by DONADAMS(op): 12:45am On Feb 11, 2019
please help out, I'm frustrated...my code isn't producing the right output...I tried debugging and still the same, I just can't discover what's wrong..it's an assignment...thanks

Re: Please Help Out by airsaylongcon: 2:46am On Feb 11, 2019
You aren't assigning a value to amt when u initialise the ba object by calling the bankAccount function. Your function just displays a value without first assigning that value to your private variable amt

amt in the class definition is a private variable and you are confusing the call that passes the amt as an assignment to the private variable. It won't work. You need to change the variable name in the function call to something else (openingBal for example) and then in the body u assign amt=openingBal before your System.out.println
Re: Please Help Out by HealerC: 10:55am On Feb 11, 2019
amt in the constructor is only in the scope of the constructor
Instead do
this.amt = amt;
in the constructor to assign the value of amt in the constructor to the global variable amt (the one outside). I still see other issues though but fix this one and see if you can figure the rest out.
Re: Please Help Out by DONADAMS(op): 10:59pm On Feb 15, 2019
airsaylongcon:
You aren't assigning a value to amt when u initialise the ba object by calling the bankAccount function. Your function just displays a value without first assigning that value to your private variable amt

amt in the class definition is a private variable and you are confusing the call that passes the amt as an assignment to the private variable. It won't work. You need to change the variable name in the function call to something else (openingBal for example) and then in the body u assign amt=openingBal before your System.out.println
thanks bro...its supposed to be openingBal=amt. it worked tho...all these constructor, accessor are confusing...I really appreciate.
Re: Please Help Out by DONADAMS(op): 11:02pm On Feb 15, 2019
HealerC:
amt in the constructor is only in the scope of the constructor
Instead do
this.amt = amt;
in the constructor to assign the value of amt in the constructor to the global variable amt (the one outside). I still see other issues though but fix this one and see if you can figure the rest out.
thanks bro..but I didn't understand this...I really appreciate
1 Reply

Who Can Help Out With This Python Problem? • Pls Python Guru Help Out • Java Programmers Plz Help Out • 2 • 3 • 4

I Need Professional Advices As Regards Programming Skill In Demand I Cud Learn • [Day 1] Thrift Collector(esusu) API In Seven Days With Django • Game App