Welcome, Guest: Register On Nairaland / LOGIN! / Trending / Recent / NewStats: 3,194,284 members, 7,954,127 topics. Date: Friday, 20 September 2024 at 12:47 PM |
Nairaland Forum / Science/Technology / Programming / Please Help Out (938 Views)
Pls Python Guru Help Out / Java Programmers Plz Help Out / Expert In The House Should Help Out, Pls. (2) (3) (4)
Please Help Out by DONADAMS(m): 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(m): 10:59pm On Feb 15, 2019 |
airsaylongcon: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(m): 11:02pm On Feb 15, 2019 |
HealerC:thanks bro..but I didn't understand this...I really appreciate |
(1) (Reply)
I Need A Good Blog. / Microsoft To Recruit 500 Software Engineers In Nigeria And Kenya / Where Do You Get The Latest Tech/startup News In Africa
(Go Up)
Sections: politics (1) business autos (1) jobs (1) career education (1) romance computers phones travel sports fashion health religion celebs tv-movies music-radio literature webmasters programming techmarket Links: (1) (2) (3) (4) (5) (6) (7) (8) (9) (10) Nairaland - Copyright © 2005 - 2024 Oluwaseun Osewa. All rights reserved. See How To Advertise. 12 |