A lottery company sells scratch cards. In addition to the gameitself, each contains a verification code. When a user wishes toclaim a win, they enter the value they are claiming and theverification code into the system. The system then uses a secretkey to determine the validity of the claim.
You are to write the verification method which will be passedthe data entered by the claimant together with the secret key.
The verification method verifyWin takes three arguments, theclaimValue in pounds as an int, the verificationCode from the cardas a String and the secretKey as a String. The prizes available are£1, £3 and £5. It returns a Boolean value, true if the claim isvalid, false if not.
To determine whether a verificationCode is valid, it is comparedto the secretKey character by character.
A local variable prize (which you must create) is initially setto 0 and will represent the prize value in the verificationCodeonce the processing has completed.
Next an appropriate loop is entered to compare the characters inthe verificationCode and the secretKey, one at a time in the orderleft to right.
Each time the code in the body of the loop executes, it examinesthe next pair of characters. If the characters at the currentposition match, the numerical position of thematch is added to the prize. If they do not match, the numericalposition is subtracted. (We take position tostart at 1, whereas strings are indexed from 0.)
When all of the characters have been compared the value in prizecontains the value of a valid claim for this card. It is comparedto the claimValue to determine if the claim is valid. If theymatch, return true. If not return false.
The keys may be different lengths, but the secretKey will alwaysbe shorter than the verificationCode. Compare only as manypositions as the shorter string
You will need the charAt() method to access the correctcharacter.
You should assume that the inputs are always valid.
*********************************************************************************
/**
*Takes three arguments:-
* claimValue - an int value representing the value claimed by theuser in pounds
* verificationCode - A String representing the verification codeprinted on the card
* secretKey - a String representing the secret key used to validatethe claim
*
* Iterates over the characters in the Strings adding the positionof matches
* and subtracting the position of mis-matches to determine theprize value
* The claim is valid if the amount claimed is equal to the prizevalue determined.
* Returns a boolean value true if the claim is valid and falseotherwise.
*/
public Boolean verifyWin(int claimValue, String verificationCode,String secretKey)
{
//create and initialise your local variable prize here
 Â
// insert your loop here
// and return your value here
}