Help squaring a variable
 CodeGuru Home VC++ / MFC / C++ .NET / C# Visual Basic VB Forums Developer.com

# Thread: Help squaring a variable

1. Junior Member
Join Date
Mar 2012
Posts
5

## Help squaring a variable

code:

decimal number1 = Convert.ToInt32(textBox1.Text);
double pi = Math.PI;
double Radius_to_Circumference = (double)number1 * 2 * pi;
double RTD = (double)number1 * 2;
double RTA = (double)Math.Pow(number1, 2) * pi;
MessageBox.Show("The circumference is " + Radius_to_Circumference + " \nThe Diameter is " + RTD + " \nThe Area is " +;

2. Elite Member
Join Date
Jun 2008
Posts
2,477

## Re: Help squaring a variable

Once again, you have not explained what the problem is. We are not your debuggers. Take some time and explain exactly what is going wrong instead of throwing some code at us and saying "make it work".

3. Junior Member
Join Date
Mar 2012
Posts
5

## Re: Help squaring a variable

The program is made to tell you all the info of a circle by only putting in the area,radius,circumference or diameter
The problem is here:
double RTA = (double)Math.Pow(number1, 2) * pi;

I wrote this afterwad and it worked:
private void button2_Click(object sender, EventArgs e)
{
decimal number = Convert.ToInt32(textBox2.Text);
double pi = Math.PI;
double DTR = (double)number / 2;
double DTC = (double)number * pi;
double DTR2 =(double) number / 2;
This is the part: double DTA = (double)Math.Pow(DTR2, 2) * pi;
Last edited by yoda493; March 15th, 2012 at 04:45 PM.

4. Elite Member
Join Date
Jun 2008
Posts
2,477

## Re: Help squaring a variable

Math.Pow already returns a double, the cast is redundant.

#### Posting Permissions

• You may not post new threads
• You may not post replies
• You may not post attachments
• You may not edit your posts
•