Programming C, C++, Java, PHP, Ruby, Turing, VB
Computer Science Canada 
Programming C, C++, Java, PHP, Ruby, Turing, VB  

Username:   Password: 
 RegisterRegister   
 Triangles
Index -> Programming, Turing -> Turing Help
View previous topic Printable versionDownload TopicSubscribe to this topicPrivate MessagesRefresh page View next topic
Author Message
Jessica359




PostPosted: 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
Sponsor
Sponsor
Sponsor
sponsor
BigBear




PostPosted: 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"]
Turing:
before
and /syntax in [] after your code
A.J




PostPosted: Tue Feb 26, 2008 7:28 pm   Post subject: Re: Triangles

or you could use Draw.Polygon

It is helpful Very Happy
Nick




PostPosted: Wed Feb 27, 2008 6:25 am   Post subject: RE:Triangles

BigBear, you can over comment
Jessica359




PostPosted: Mon Mar 10, 2008 3:40 pm   Post subject: RE:Triangles

Awesome thanks!
There is no such thing as over commeting Wink
Tallguy




PostPosted: Thu Apr 03, 2008 7:53 am   Post subject: RE:Triangles

what unit did we do that program in jess?
andrew.




PostPosted: 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.
BigBear




PostPosted: 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.
Sponsor
Sponsor
Sponsor
sponsor
Display posts from previous:   
   Index -> Programming, Turing -> Turing Help
View previous topic Tell A FriendPrintable versionDownload TopicSubscribe to this topicPrivate MessagesRefresh page View next topic

Page 1 of 1  [ 8 Posts ]
Jump to:   


Style:  
Search: