# Loops :: cpt

The Swedish Farmer System is a process for determining the product of 2 positive integers using only multiplication by two, division by two and addition. This algorithm can be stated as follows: Write each number (the multiplier and the multiplicand) at the head of the column. Double the number in the first column, and halve the number in the second column. If the number in the second column is odd, ignore the remainder when dividing. If the number in the second column is even, cross out that entire row after dividing. Keep doubling, halving and crossing out until the number in the second column is 1. Add up the remaining numbers in the first column. The total is the product of your original numbers.Save as XXXXLoops. Here is an example,determining the product of 57 x 86 = 4902 57 86 (cross out row, do not show in output) 114 43 228 21 456 10 (cross out row, do not show in output) 912 5 1824 2 (cross out row, do not show in output) 3648 1 4902 Write a class that prompts the user for a multiplier and a multiplicand and uses this algorithm to determine the product. Your class must also show the intermediate steps the algorithm takes by printing out any row where an addition is required in the first column. Your program should continue prompting the user for input until 2 zeros are entered. This should end the program. Negatives values entered should be rejected. If one value is zero and the other is positive, the program should give the correct result without using the algorithm. Your program should function as shown below: Multiplier: 57 Multiplicand: 86 114 43 228 21 912 5 3648 1 Product: 4902 Multiplier: 48 Multiplicand: -36 Values must not be negative Multiplier: 27 Multiplicand: 0 Product: 0 Multiplier: 0 Multiplicand: 0To view rubric click here