//The following code should work for you.
// You should be able to copy and paste this whole answer
// as all notes including these are commented out.
// You could refine this by ensuring only whole numbers are entered
using System;
namespace SquareCubed
{
class YahooAnswerMath
{
static void Main(string[] args)
{
string InputNumber; // holds the number entered.
int ConvertedInputNumber; // The input string needs to be converted to an integer to do the math
int SquaredNumber, CubedNumber; // declare the variables
// Tell the user to enter a number
Console.WriteLine(" Enter a number");
InputNumber = Console.ReadLine(); // get the number
// Force the Input string to an Integer
ConvertedInputNumber = Convert.ToInt32(InputNumber);
// Do the math
SquaredNumber = ConvertedInputNumber * ConvertedInputNumber;
CubedNumber = ConvertedInputNumber * ConvertedInputNumber * ConvertedInputNumber;
//Display the number entered and the results
Console.WriteLine(" You entered " + InputNumber);
Console.WriteLine(" The number you entered squared = " + SquaredNumber);
Console.WriteLine(" The number you entered cubed = " + CubedNumber);
Console.WriteLine("Hit the enter key to exit this program");
Console.ReadLine();// If you compile you will need this to keep the program from closing
}
}
}
// Hope this helps
// Mark D.