Power Calculation - C#

A simple Space Bar Press Interaction to make the calculation run, and I made the floats public for easy testing.

‘’ public class PowerCalculation : MonoBehaviour
{
public float numberToCalculate, powerToRaise;

// Start is called before the first frame update
void Start()
{
    
}
private void Calculate()
{
    if(Input.GetKeyDown(KeyCode.Space))
    {
        Debug.Log( numberToCalculate + " raised to the " + powerToRaise + "th power, equals " + Mathf.Pow(numberToCalculate, powerToRaise));
    }
}
// Update is called once per frame
void Update()
{
    Calculate();
}

}’’

Sorry, its been a while since Ive posted Script and cant remember how to make it more readable.

This topic was automatically closed 20 days after the last reply. New replies are no longer allowed.

Privacy & Terms