· 7 years ago · Dec 18, 2018, 11:30 PM
1 public boolean verifyWin(int claimValue, String verificationCode, String secretKey)
2 {
3 //create and initialise the prize variable to zero here
4 int prize = 0;
5 int iterations = 0;
6 int counter = 1;
7 // insert your loop here
8 if (verificationCode.length() > secretKey.length())
9 {
10 iterations = secretKey.length();
11 }
12 else
13 {
14 iterations = verificationCode.length();
15 }
16 for (int i = 0; i < iterations; i++)
17 {
18 if (verificationCode.charAt(i) == secretKey.charAt(i))
19 {
20 prize = prize + counter;
21 counter = counter + 1;
22 }
23 else
24 {
25 prize = prize - counter;
26 counter = counter + 1;
27 }
28 }
29 // and return your value here
30 if (prize == claimValue)
31 {
32 return true;
33 }
34 else
35 {
36 return false;
37 }
38 }