Question
The Russian peasant algorithm for multiplication uses the decrease by a constant factor approach to developing an algorithm. For this assignment, create a Java class
The Russian peasant algorithm for multiplication uses the decrease by a constant factor approach to developing an algorithm.
For this assignment, create a Java class that has three fields, two factors and one product (all ints).
Then write a method that implements this algorithm (see text section 4.4) using a loop. Then write a second method that implements this algorithm using recursion. Write any other methods needed to retrieve the needed values.
Write a Driver class with main( ) that allows the user to enter two integer factors and call one or both of the methods to obtain the product. Print the product to the screen.
Step by Step Solution
There are 3 Steps involved in it
Step: 1
Get Instant Access to Expert-Tailored Solutions
See step-by-step solutions with expert insights and AI powered tools for academic success
Step: 2
Step: 3
Ace Your Homework with AI
Get the answers you need in no time with our AI-driven, step-by-step assistance
Get Started