TORONTO KIDS COMPUTER CLUB | Markham Saturday 14:00 Java Homework 20.01.04.
16850
post-template-default,single,single-post,postid-16850,single-format-standard,ajax_fade,page_not_loaded,,qode-theme-ver-7.6.2,wpb-js-composer js-comp-ver-6.10.0,vc_responsive

Markham Saturday 14:00 Java Homework 20.01.04.

09 Jan Markham Saturday 14:00 Java Homework 20.01.04.

Question:
Write a method luckySum(int a, int b, int c) to calculate sum of given 3 int values, a b c. The function will have a return value of 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.

Sample Input 1:
a: 1
b: 2
c: 3

Sample Output 1
The lucky sum is 6

Sample Input 2:
a: 1
b: 2
c: 13

Sample Output 2:
The lucky sum is 3
(Because c is 13, c does not count towards the sum)

Sample Input 3:
a: 1
b: 13
c: 3

Sample Output 3
The lucky sum is 1
(Because b is 13, both b and c does not count towards the sum)

No Comments

Sorry, the comment form is closed at this time.