Answered by:
Small Basic
Question

Hey i'm having trouble with a certain part of the Small Basic Curriculum, i cant figure out how to write a program that calculates the area and circumference of a circle based on its diameter. Can anyone help me understand what to do?
Thanks, ScikoticRage
 Moved by Mr. Wharty Thursday, May 16, 2013 3:34 AM
Answers

Ok, i will explain this as best i can.
Ask the user for the diameter of the circle. then, to find the circumference, use this:
You could go:
circum = 3.14 * diameter (or what ever you name the variables)
Then,Find the area:
area = 3.14 * (diameter / 2)
(note, i used parentheses to that it wouldn't go like 3.14 * diameter then that answer divided by 2.
code:
TextWindow.WriteLine("Enter in the diameter of a circle: ") diameter = TextWindow.Read() circum = 3.14 * diameter area = 3.14 * (diameter / 2) TextWindow.WriteLine("The area is: " + area) TextWindow.WriteLine("The circumference is: " + circum)
Help? If it doesn't, i'll gladly remake this and explain it. :3
I am a 12 year old learning how to code using small basic.
 Edited by 8Bit Pony Thursday, May 16, 2013 4:58 PM
 Proposed as answer by Ed Price  MSFTMicrosoft employee, Owner Saturday, May 18, 2013 10:53 PM
 Marked as answer by Nonki TakahashiModerator Sunday, May 26, 2013 12:49 AM

For the area you should square the diameter/2 as:
diameter*diameter/4
Jan [ WhTurner ] The Netherlands
 Proposed as answer by Ed Price  MSFTMicrosoft employee, Owner Saturday, May 18, 2013 10:53 PM
 Marked as answer by Nonki TakahashiModerator Sunday, May 26, 2013 12:49 AM

For the area you do: A = ((d / 2) * (d / 2)) * 3.14
"D" would be the diameter
Its not "area = 3.14 * (diameter / 2)" Its radius squared times pi.
See here: http://www.mathgoodies.com/lessons/vol2/circle_area.html
It is written: "'As surely as I live,' says the Lord, 'every knee will bow before me; every tongue will acknowledge God.'" Romans 14:11
 Proposed as answer by Ed Price  MSFTMicrosoft employee, Owner Saturday, May 18, 2013 10:53 PM
 Marked as answer by Nonki TakahashiModerator Sunday, May 26, 2013 12:49 AM

So like this:
TextWindow.Write("Enter the diameter: ") Dia = TextWindow.Read() Area = ((Dia / 2) * (Dia / 2)) * 3.14 TextWindow.WriteLine("The area is " + Area)
It is written: "'As surely as I live,' says the Lord, 'every knee will bow before me; every tongue will acknowledge God.'" Romans 14:11
 Proposed as answer by Ed Price  MSFTMicrosoft employee, Owner Saturday, May 18, 2013 10:53 PM
 Marked as answer by Nonki TakahashiModerator Sunday, May 26, 2013 12:49 AM
All replies

Ok, i will explain this as best i can.
Ask the user for the diameter of the circle. then, to find the circumference, use this:
You could go:
circum = 3.14 * diameter (or what ever you name the variables)
Then,Find the area:
area = 3.14 * (diameter / 2)
(note, i used parentheses to that it wouldn't go like 3.14 * diameter then that answer divided by 2.
code:
TextWindow.WriteLine("Enter in the diameter of a circle: ") diameter = TextWindow.Read() circum = 3.14 * diameter area = 3.14 * (diameter / 2) TextWindow.WriteLine("The area is: " + area) TextWindow.WriteLine("The circumference is: " + circum)
Help? If it doesn't, i'll gladly remake this and explain it. :3
I am a 12 year old learning how to code using small basic.
 Edited by 8Bit Pony Thursday, May 16, 2013 4:58 PM
 Proposed as answer by Ed Price  MSFTMicrosoft employee, Owner Saturday, May 18, 2013 10:53 PM
 Marked as answer by Nonki TakahashiModerator Sunday, May 26, 2013 12:49 AM

For the area you should square the diameter/2 as:
diameter*diameter/4
Jan [ WhTurner ] The Netherlands
 Proposed as answer by Ed Price  MSFTMicrosoft employee, Owner Saturday, May 18, 2013 10:53 PM
 Marked as answer by Nonki TakahashiModerator Sunday, May 26, 2013 12:49 AM

For the area you do: A = ((d / 2) * (d / 2)) * 3.14
"D" would be the diameter
Its not "area = 3.14 * (diameter / 2)" Its radius squared times pi.
See here: http://www.mathgoodies.com/lessons/vol2/circle_area.html
It is written: "'As surely as I live,' says the Lord, 'every knee will bow before me; every tongue will acknowledge God.'" Romans 14:11
 Proposed as answer by Ed Price  MSFTMicrosoft employee, Owner Saturday, May 18, 2013 10:53 PM
 Marked as answer by Nonki TakahashiModerator Sunday, May 26, 2013 12:49 AM


So like this:
TextWindow.Write("Enter the diameter: ") Dia = TextWindow.Read() Area = ((Dia / 2) * (Dia / 2)) * 3.14 TextWindow.WriteLine("The area is " + Area)
It is written: "'As surely as I live,' says the Lord, 'every knee will bow before me; every tongue will acknowledge God.'" Romans 14:11
 Proposed as answer by Ed Price  MSFTMicrosoft employee, Owner Saturday, May 18, 2013 10:53 PM
 Marked as answer by Nonki TakahashiModerator Sunday, May 26, 2013 12:49 AM

This is my conclusion.
Sample of Small Basic Curriculum "The Pi Property" isTextWindow.Write("Enter the radius of the circle:") Radius = TextWindow.Read() Area = Math.Pi * Math.Power(Radius, 2) TextWindow.WriteLine("Area of the Circle is " + Area)
So base on diameter:
TextWindow.Write("Enter the diameter of the circle:") Diameter = TextWindow.Read() Radius = Diameter / 2 Area = Math.Pi * Math.Power(Radius, 2) TextWindow.WriteLine("Area of the Circle is " + Area) Circum = 2 * Math.Pi * Radius TextWindow.WriteLine("Circumference of the Circle is " + Circum)
Nonki Takahashi

This is my conclusion.
Sample of Small Basic Curriculum "The Pi Property" isTextWindow.Write("Enter the radius of the circle:") Radius = TextWindow.Read() Area = Math.Pi * Math.Power(Radius, 2) TextWindow.WriteLine("Area of the Circle is " + Area)
So base on diameter:
TextWindow.Write("Enter the diameter of the circle:") Diameter = TextWindow.Read() Radius = Diameter / 2 Area = Math.Pi * Math.Power(Radius, 2) TextWindow.WriteLine("Area of the Circle is " + Area) Circum = 2 * Math.Pi * Radius TextWindow.WriteLine("Circumference of the Circle is " + Circum)
Nonki Takahashi
Should we make a change to the curriculum to make it easier to understand?
Thanks!
Ed Price (a.k.a User Ed), SQL Server Customer Program Manager (Blog, Small Basic, Wiki Ninjas, Wiki)
Answer an interesting question? Create a wiki article about it!