Hi,
For the StringHelperClass task, I've got it right but then I had a look at the solution to compare. I don't understand it. Can someone please explain in to me? Don't understand sb was created and why append is used.
Thanks in advance :)
Just a more tedious way to do it by appending the string by the count times. Way easier to just use .repeat
BrentachiiLevel 13, United States of America, United States
24 January 2022
The calculator task is odd... I tried (b * 100.0) / a; that outputs correctly but it won't take it as correct.
Is it just me or does that seem like if it wanted me to use a specific method of calculation they should have specified it exactly how they want it?
!! edit !! I found out this answer was totally wrong thanks to some awesome people.
BrentachiiLevel 13, United States of America, United States
25 January 2022
someone helped me I was going about it the wrong way I needed to first multiply a and b then divide.
I don't think you need a separate 1.0 step because the 100.0 makes it a floating-point number but if someone knows if that is right then please let me know
In Body Mass Index I passed the solution but I have this error in INTELLIJ IDEA
Exception in thread "main" java.lang.NumberFormatException: For input string: "68.4"
at java.lang.NumberFormatException.forInputString(NumberFormatException.java:65)
at java.lang.Integer.parseInt(Integer.java:580)
at java.lang.Integer.parseInt(Integer.java:615)
at com.codegym.task.task05.task0532.Solution.main(Solution.java:13)
I need help to solve this... please...
Static method vs non-static i.e instance method - More i do more i get confused.
Can someone share some good idea with example to refresh my head, please?
What i understood is:
Static method are those method if happen to use than than we just use the classname.method()
Non-static method if want to use: then we need to create a class instance like Cat cat = new Cat() and to access its values we use this
is that right? Argh, i am so confused with static and non static
Any help with example would be very very appreciated
Thanks
Might be wrong but....
Static is basically when it's standalone and can be used by itself, like adding to a count that doesn't have to do with any objects or anything. count(5); increases the count by 5.
Non-static are not standalone and are used with objects, so instead of adding to a non specific count we want to increase the count of cat objects or something.
Cat jim = new Cat()
jim.count(5);
There are now 5 Jims, this is by far too many Jims.
It doesn't just have to be objects either, it can also be classes and stuff. In short static is standalone and can just be called thing(); non-static means you need to use it with something like an object cat.thing();
There is more to it, but this is a basic level if I understand it right. I hope this helps a bit.
Calculator task is poorly explained particularly for the percent method. Either it should be clarified or taken down from the question altogether. The answer for this one does not seem to be convincing.
Quoting a previous users comment on 20 January 2019 and I agree with the comment still in 2021 : "I am a mathematician and I cannot appreciate the logic that b as a % of a is (b/100)*a. b as a percentage of a is always b/a * 100. For the sake of programming the rules of mathematics particularly as a major part of the world understands should not be changed. Please correct this error in your lessons."
please update this question!
Guys! I have found the key to solving the Calculator task easily! Here's what will help you a lot!;
(This is a new concept. Keep that in mind. :).).
For the multiply and divide problems, use this to help you;
GO TO FULL VERSION