Placeholder

CSIS 209 Programming Assignment 3

$7.99

Description

Write a recursive method called Power(base, exponent) that, when called, returns [latex] base^{exponent}[/latex].
For example:
Power (3, 4) = 3 * 3 * 3 * 3.
Assume that exponent is an integer greater than or equal to 1. The recursion step should use the relationship: [latex]{base}^{exponent}={base}*{base}^{exponent-1}[/latex]
The terminating condition occurs when exponent is equal to 1 because [latex]base^1 = base[/latex]
Incorporate this method into an application that enables the user to enter the base and exponent.
Requirements:
In the Main() method, declare three arrays of long data types: baseNumbers, exponents, and results. Each array should be created to hold exactly 5 members.
Using a FOR loop, populate the baseNumbers array with random integers between 1 and 50 and populate the exponents array with random integers between 1 and 10. Use a random number generator to create these random numbers.
Using another FOR loop, call the Power method, passing it a member of the baseNumbers array and a member of the exponents array for each iteration of the loop. Store the returned values in the results array.
The Power method should use the algorithm described above and MUST be recursive, taking two longs as arguments and returning a long data type.
Create another method called PrintArrays that takes as arguments the three arrays you created above and returns void. The method should print a header as “Base”, “Exponent”, and “Result” with each word separated with a single tab character.
Using a FOR loop, iterate over each array using the GetUpperBound method to determine the condition for which the loop terminates. For each iteration of the loop, print out the base, exponent, and result from each array under the appropriate column headings.
(Hint: You may need to use one or more tabs to separate the data values to make them line up with the headers above.)
The Main() method should call the PrintArrays method, passing in the three arrays as arguments.
SCREENSHOTS
SOLUTION
PAYMENT
The solution includes a Visual Studio (c#) project
Attachments [Move over files to preview content of those files]
CSIS209_Programming_Assignment_3.zip (124.65 KB)
CSIS209-Programming-Assignment-3-Screenshot.png
Visual Studio project
CSIS209ProgrammingAssignment3
CSIS209ProgrammingAssignment3
App.config
bin
Debug
CSIS209ProgrammingAssignment3.vshost.exe
CSIS209ProgrammingAssignment3.vshost.exe.config
CSIS209ProgrammingAssignment3.vshost.exe.manifest
CSIS209ProgrammingAssignment3.csproj
obj
Debug
DesignTimeResolveAssemblyReferencesInput.cache
TempPE
Program.cs
Properties
AssemblyInfo.cs
CSIS209ProgrammingAssignment3.sln
CSIS209ProgrammingAssignment3.v12.suo
Preview Program.cs
// xxxxxxxxx xxxxxxxx
// xxxxx(xxxx, xxxxxxxx) = xxxx * xxxxx(xxxx, xxxxxxxx – 1)
xxxxxx xxxxxx xxxx xxxxx(xxxx xxxx, xxxx xxxxxxxx)
{
if (Exponent == 0) return 1; else return Base * Power(Base, Exponent – 1); }
public static void PrintArrays(long[] baseNumbers, long[] exponents, long[] results) { // Print a header as “Base”, “Exponent”, and “Result” with each word separated with a single tab character. Console.WriteLine(“BasettExponentttResult”); int index = 0; while (true)
{
xxxxxxx.xxxxxxxxx(xxxxxxxxxxx[xxxxx] + “xx” + xxxxxxxxx[xxxxx] + “xxx” + xxxxxxx[xxxxx]);
xx (xxxxx >= xxxxxxx.xxxxxxxxxxxxx(0)) // xxxxx xxx xxxxxxxxxxxxx xxxxxx xx xxxxxxxxx xxx xxxxxxxxx xxx xxxxx xxx xxxx xxxxxxxxxx
{
xxxxx;
}
Price: $15
Buy Now
Checkout
Added to cart
Buy More Save More
Buy at least TWO items & save up to 30% OFF your ENTIRE order!
Rack up instant rebates in your shopping cart. Simply add items to your cart, and see the savings add up.
Discounts will automatically be applied on eligible orders.
CSIS 209 Programming Assignment 3 – $15.00
CSIS 209 Programming Assignment 4 – $19.00
CSIS 209 Programming Assignment 5 – $19.00
CSIS 209 Programming Assignment 6 – $19.00
CSIS 209 Programming Assignment 7 – $19.00
CSIS 209 Programming Assignment 8 – $25.00
Add to Cart
Checkout
Added to cart
You May Also Like:
CSIS 209 Programming Assignment 1
CSIS 209 Programming Assignment 2
CSIS 209 Programming Assignment 4
CSIS 209 Programming Assignment 5
CSIS 209 Programming Assignment 6
CSIS 209 Programming Assignment 7
CSIS 209 Programming Assignment 8

Reviews

There are no reviews yet.

Only logged in customers who have purchased this product may leave a review.