r/learnjava • u/asna_nazar • Apr 18 '15
plz help me
Given 3 int values, a b c, return their sum. However, if one of the values is 13 then it does not count towards the sum and values to its right do not count. So for example, if b is 13, then both b and c do not count. Use the following template for writing your function: public int not13(int a, int b, int c){ } Expected Input: 1 2 3 Expected Output: 6
0
Upvotes
2
u/quietnick Apr 18 '15
Put the values into an array.
Iterate over the values, if the value is 13, exit the array, else add the value.
-8
u/asna_nazar Apr 18 '15
plz solv it
4
u/BertRenolds Apr 18 '15
"learn java" if you want someone to do your homework, there is a sub for that
4
u/Philboyd_Studge Apr 18 '15
How would you do this on paper?