
March 15th, 2012, 03:36 PM
#1
Help squaring a variable
I want to square a variable. Please help me.Here is my code:
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 " +;

March 15th, 2012, 03:53 PM
#2
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".
If you liked my post go ahead and give me an upvote so that my epee.... ahem, reputation will grow.
Yes; I have a blog too  http://theangrygorilla.com/

March 15th, 2012, 05:36 PM
#3
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 05:45 PM.

March 15th, 2012, 06:06 PM
#4
Re: Help squaring a variable
Math.Pow already returns a double, the cast is redundant.
If you liked my post go ahead and give me an upvote so that my epee.... ahem, reputation will grow.
Yes; I have a blog too  http://theangrygorilla.com/
Posting Permissions
 You may not post new threads
 You may not post replies
 You may not post attachments
 You may not edit your posts

Forum Rules

Click Here to Expand Forum to Full Width
This is a CodeGuru survey question.
Featured
