Triangles
Author |
Message |
Jessica359
![](http://compsci.ca/v3/uploads/user_avatars/7434636574818b0e9b7877.gif)
|
Posted: Mon Feb 25, 2008 2:37 pm Post subject: Triangles |
|
|
ok so we have to ask a use for the base and height of the triangle to get the surface area. But we also need to give them a picture of that triangle. How do you make a triangle that meets the users entries?
Code:
var base :real
var height: real
var diameter: real
var radius: real
put "What is the base of the triangle?"
get base
put "What is the height of the triangle?"
get height
put "The area of your triangle is ",base*height/2
delay(1500)
cls
put "What is the diameter of the circle"
get diameter
put "The area of your circle is ",3.14*diameter
radius :=diameter/2
Draw.Oval (50,50,round (radius),round (radius),50)
delay(1500)
cls
drawline (250,250,300,310,2)
drawline (300,310,350,250,2)
drawline (250,250,350,250,2)
drawfill (275,275,1,2)
thanks |
|
|
|
|
![](images/spacer.gif) |
Sponsor Sponsor
![Sponsor Sponsor](templates/subSilver/images/ranks/stars_rank5.gif)
|
|
![](images/spacer.gif) |
BigBear
|
Posted: Mon Feb 25, 2008 3:02 pm Post subject: Re: Triangles |
|
|
After you get the dimensions the length of the base and the hieght you could set an intially point for the bottom line and add the length that they want
Turing: | var base : int
get base
drawline(100, 100, 100+base, 100, 1) |
Then you ask them for the hight.
Turing: | var base, high : int % declares variables used in program
put "How big would you like the base of your triangle in pixels?" %Displays the question for entry of base variable
get base %hold the length of the bottom line of the triangle
drawline(100, 100, 100+base, 100, 1) %draws the bottom line of the triangle in blue
put "How high would you like the triangle to go in pixels?" %Displays instructions for the user to enter the hight
get high %gets input from the user and holds the hight of the triangle
drawline (100, 100, 100+base div 2, 100+high, 2) %Draws the left line of the triangle starting at 100, 100 (intially point chossen to draw triangle) and draws it over half of the base and up by the amount entered by the user
drawline ( 100 +base, 100 , 100+base div 2, 100+high, 6) %Draws the right side of the triangle starting at the left end of the base and up the number entered by the user for hight and over half as much as the length of the line of the base
%the 1, 2, 6, are the colors of the lines to help you see how to draw them
|
So once you choose a starting point just use the input to draw the sides.
Hope this helps. Also for future posts use code tags meaning type this before your code code: | [code]%code here and this after your code [/code] | Or to make it look like turing use [syntax="Turing"] and /syntax in [] after your code |
|
|
|
|
![](images/spacer.gif) |
A.J
![](http://compsci.ca/v3/uploads/user_avatars/119833057151651227b0d87.gif)
|
Posted: Tue Feb 26, 2008 7:28 pm Post subject: Re: Triangles |
|
|
or you could use Draw.Polygon
It is helpful ![Very Happy Very Happy](http://compsci.ca/v3/images/smiles/icon_biggrin.gif) |
|
|
|
|
![](images/spacer.gif) |
Nick
![](http://compsci.ca/v3/uploads/user_avatars/19644337547e837b41d67a.png)
|
Posted: Wed Feb 27, 2008 6:25 am Post subject: RE:Triangles |
|
|
BigBear, you can over comment |
|
|
|
|
![](images/spacer.gif) |
Jessica359
![](http://compsci.ca/v3/uploads/user_avatars/7434636574818b0e9b7877.gif)
|
Posted: Mon Mar 10, 2008 3:40 pm Post subject: RE:Triangles |
|
|
Awesome thanks!
There is no such thing as over commeting ![Wink Wink](http://compsci.ca/v3/images/smiles/icon_wink.gif) |
|
|
|
|
![](images/spacer.gif) |
Tallguy
![](http://compsci.ca/v3/uploads/user_avatars/515706924539b443d32a6e.gif)
|
Posted: Thu Apr 03, 2008 7:53 am Post subject: RE:Triangles |
|
|
what unit did we do that program in jess? |
|
|
|
|
![](images/spacer.gif) |
andrew.
|
Posted: Mon Apr 07, 2008 6:18 pm Post subject: Re: Triangles |
|
|
Is this what you wanted?
Turing: | var base : real
var height : real
var diameter : real
var radius : real
put "What is the base of the triangle?"
get base
put "What is the height of the triangle?"
get height
put "The area of your triangle is ", base * height / 2
drawline (maxx div 2 - (base div 2), maxy div 2 - (height div 2), maxx div 2 + (base div 2), maxy div 2 - (height div 2), black)
drawline (maxx div 2, maxy div 2 + (height div 2), maxx div 2 - (base div 2), maxy div 2 - (height div 2), black)
drawline (maxx div 2, maxy div 2 + (height div 2), maxx div 2 + (base div 2), maxy div 2 - (height div 2), black)
put "Press any key to continue..."..
Input.Pause
cls
put "What is the diameter of the circle"
get diameter
put "The area of your circle is ", 3. 14 * diameter
radius := diameter / 2
Draw.Oval (maxx div 2, maxy div 2, round (radius ), round (radius ), black)
put "Press any key to quit..."..
Input.Pause
cls |
The only thing that I put in is the drawline thing to draw your triangle, and I made the circle center, and I also made it so you press any key to continue. |
|
|
|
|
![](images/spacer.gif) |
BigBear
|
Posted: Mon Apr 07, 2008 8:51 pm Post subject: Re: Triangles |
|
|
I thought this problem was solved, also the circle part was understood and posted in the beginning. |
|
|
|
|
![](images/spacer.gif) |
Sponsor Sponsor
![Sponsor Sponsor](templates/subSilver/images/ranks/stars_rank5.gif)
|
|
![](images/spacer.gif) |
|
|