0% found this document useful (0 votes)
31 views

Recursive Programming Problem

The document describes a recursive programming problem to write a Java program that prompts a user for a number, uses recursion to calculate that number multiplied by 3 without using the multiplication operator, and displays the product. It should use a sentinel value to allow the user to quit. It provides an example user input and output and hints that multiplication can be viewed as repeated addition.

Uploaded by

Akash Patel
Copyright
© © All Rights Reserved
Available Formats
Download as DOCX, PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
31 views

Recursive Programming Problem

The document describes a recursive programming problem to write a Java program that prompts a user for a number, uses recursion to calculate that number multiplied by 3 without using the multiplication operator, and displays the product. It should use a sentinel value to allow the user to quit. It provides an example user input and output and hints that multiplication can be viewed as repeated addition.

Uploaded by

Akash Patel
Copyright
© © All Rights Reserved
Available Formats
Download as DOCX, PDF, TXT or read online on Scribd
You are on page 1/ 1

Recursive Programming Problem

Write a JAVA program that repeatedly prompts your user for a number, uses
a recursive function to calculate the product of that number times three (3),
and displays the product. Select a sentinel value that allows your user to
quit. Do NOT use the multiplication operator (*) in your proposed solution.

User Inputs: Recursive Function Returns:


-2 -6
-1 -3
0 0
1 3
2 6
3 9
4 12

Hint: Think of multiplication as a series of additions.

Recursive Function
User Inputs: Performs: Returns:
1 3 3
2 3+3 6
3 3+3+3 9
4 3+3+3+3 12

You might also like