Academic Integrity: tutoring, explanations, and feedback — we don’t complete graded work or submit on a student’s behalf.

This assignment will give you an opportunity to learn about using algorithm desi

ID: 662213 • Letter: T

Question

This assignment will give you an opportunity to learn about using  algorithm design in OOP.

Complete the following programs.

Factorial numbers

In this assignment, you will write a program that provides the following  features:

The program will provide an interface that includes the following:

A factorial button

A recursion log (the multiline text box on the right of the interface)

The program should perform the following functions:

User can enter an integer from 1 to 10.

When the user clicks the Factorial button, the program should  compute and display the integer's factorial.

The recursion log should display a message indicating when each  recursive call was made.

The interface should also indicate when the base case is reached, and it  should list all values returned.

Save the program as Factional.cpp

=====

I need help understanding how to code for the btnClick to obtain the number from my text box, factorial the number, and print result to a log box. I do not want the answer just handed to me. Any assistance would be helpful, as my instructor likes to take days to respond, and classmates are not helping out any either.

Explanation / Answer

Answer

//Factional.h

public ref class CAlgebra
{
public:
    CAlgebra(void);

    long Factorial(long x);
  
};

// Factional.cpp

CAlgebra::CAlgebra(void)
{
}

long CAlgebra::Factorial(long x)
{
    if( x <= 1 )
   return 1;
    else
        return x * Factorial(x - 1);
}

namespace Algebra1 {
System::Void btnCalculateFactorial_Click(System::Object sender,
                   System::EventArgs e)
{
    long result;
    long number = 0;
    CAlgebra statistics = gcnew CAlgebra;

  
        number = long::Parse(txtFactorialNumber->Text);
if (number > 0 && number < 11) {
        result = statistics->Factorial(number);
        txtFactorial->Text = result.ToString();
}
else
{
MessageBox::Show ("Please enter an integer that is between 1 and 10");
    }
  
};
}

Hire Me For All Your Tutoring Needs
Integrity-first tutoring: clear explanations, guidance, and feedback.
Drop an Email at
drjack9650@gmail.com
Chat Now And Get Quote