Back

Punto - Banco - Adding up two values - 5

We are going to have to add up cards a few times. Because we are going to have to do this a few times, it again makes sense to write a function for this job. The algorithm for this function is as follows:

Get two values (or cards)
Get the value of the first card by calling the function checkCard()
Get the value of the second card by calling the function checkCard()
Convert the values into integers
Add the values
If the total >= 10
    subtract 10 from the total
return the total

Q1. Modify your existing program and get it working.

punto4

Remember, the total is the Punto Banco total so you only count the last digit. Check the answers carefully. Does it all seem to work?

Q2. Alter the program for a thousand tests and then randomly skip through the results, perhaps checking a dozen. 

We now have the helper functions we need to write the main program. We will look at this in the next section. 

Back