java - The method returns true if the integer is divisible by 3 and returns false if the integer is not divisible by 3 -
That's what I've done so far; I have to use this main method.
public class HW4 {public static boolean is divisiblebittithy (string n) {int sum = 0; Intestine value; For (int k = 0; k & lt; n.length (); k ++) {char ch = n.charAt (k); Value = character Dirty value (ca); Yoga = yoga * value; } Refund amount * 3 == 0; }} It always comes true and I'm actually stuck in this part. So if you can, can you help me?
A sum is a cumulative extra ( Not multiplied). Replace this line:
sum = sum * value; to
sum = sum + value; Or more abridged version:
sum + = value;
Comments
Post a Comment