Alright, so I wrote a prgm to calculate a hexagon based pyramid;



Now I want to clean it up; Title, displaying multiple answers, if possible have low case letters..

Basically the final prgm would be called Pyramid and would have a list with regular bases; triangle, rectangle, penta, hexa, octo.

after selecting the base It would prompt you for variables, then give you multiple answers.

For example;
Hexagon based pyramid;

Variables:
one side of the hexagon (A)
The pyramid's apothem (B)

Displayed answers;
Hexagon apothem
Pyramid apothem
Pyramid height
Hexagon area
Lateral area
Volume

This is how I thought it would be written...


But I get a syntax error.
Somebody correct me if I'm wrong, but isn't Disp's syntax this: Disp "Text", Var etc and interchangable.
So I think your syntax error is coming from your Disp commands, toss in a few commas and it should be better. Same with the Input commands.
You're almost right, but there should be no spaces at all, so, for example, your code would be:

Code:
Input "Side A:",A
Input "Arrete B:",B

...

Disp "Hexagone apothem:",C
Disp "Pyramid apothem:",D
...


As a side note, screenshots of code are not great. You should copy the code and paste it.
Still incorrect :S

Currently the code looks like this;


Code:
Input "Side A:", A
Input "Arrete B:", B
sqrt((A^^2)-((0.5*A)^^2))->C
sqrt((B^^2)-((0.5*A)^^2))->D
sqrt(D^^2-C^^2)->E
(3A^^2sqrt(3))/2->F
Disp "Hexagone apothem:", C
Disp "Pyramid apothem:", D
Disp "Pyramid height:", E
Disp "Hexagon area:", F
Disp "Lateral area:", (A*D/2)*6
Disp "Pyramid volume:", (1/3*F*E)
You still have spaces after your commas.
Yes my bad, removed them, the prgm runs now, but shuts down with a syntax error after going all matrix on me.

*EDIT: bayum, nice. Thanks.

Now only problem is I can't see all the results :S
Writing being big and all, any way to mod that?

prgm wrks like this:


Code:
Input "Side A:",A
Input "Arrete B:",B
sqrt((A^^2)-((0.5*A)^^2))->C
sqrt((B^^2)-((0.5*A)^^2))->D
sqrt(D^^2-C^^2)->E
(3A^^2sqrt(3))/2->F
Disp "Hexagone apothem:",C
Disp "Pyramid apothem:",D
Disp "Pyramid height:",E
Disp "Hexagon area:",F
Disp "Lateral area:",(A*D/2)*6
Disp "Pyramid volume:",(1/3*F*E)
You could change your display to the graph screen which will allow for smaller text and more than a 8x16 display.

Code:

Text(1,1,"Hexagon apothem:",C

And if you did want big text there is a way to change that on the graph screen, meaning you can have home display font or graph font.

Code:

Text(-1,1,1,"Hexagon apothem:",C

And I made the text at 1,1 but you can change that to be any y,x coordinates with 0 being the top and 57 being the bottomost readable.
As for the x it generally can be between 0 and 94.
And now to make it perfect, any way to remove the graph lines and only have text?
You can use FnOff (and some others, follow the link).
Works beautifully guys! Thanks a ton!


Code:
Input "Side A:",A
Input "Apothem B:",B
sqrt((A^^2)-((0.5*A)^^2))->C
sqrt((B^^2)-((0.5*A)^^2))->D
sqrt(D^^2-C^^2)->E
(3A^^2sqrt(3))/2->F
(A*D/2)*6->G
(G+F)->H
(1/3*F*E)->I
AxesOff
Text(5,0,"Aire base:",F
Text(15,0,"Hauteur:",E
Text(25,0,"Apothem:",D
Text(35,0,"Aire laterale:",G
Text(45,0,"Aire totale:",H
Text(55,0,"Pyramid volume:",I
Great! Now, let's talk about optimization Smile First off, you can leave off ending parens if you're using ->. Additionally, you don't need the * for multiplication. So, for example, here's a smaller version of you program that acts the same way:

Code:
Input "Side A:",A
Input "Apothem B:",B
sqrt(A^^2-(.5A)^^2->C
sqrt(B^^2-(.5A)^^2->D
sqrt(D^^2-C^^2->E
(3A^^2sqrt(3))/2->F
3AD->G
G+F->H
FE/3->I
AxesOff
Text(5,0,"Aire base:",F
Text(15,0,"Hauteur:",E
Text(25,0,"Apothem:",D
Text(35,0,"Aire laterale:",G
Text(45,0,"Aire totale:",H
Text(55,0,"Pyramid volume:",I

Should be the same functionally.
You could even add a few optimizations to your code. For example, your calculations can be shortened.

Code:
sqrt((A^^2)-((0.5*A)^^2))->C

could be

Code:
sqrt(A^^2-.25A^^2->C
Now everything worked.. why am I getting this cluster all of a sudden??



#Solved, nvm! Very Happy
  
Register to Join the Conversation
Have your own thoughts to add to this or any other topic? Want to ask a question, offer a suggestion, share your own programs and projects, upload a file to the file archives, get help with calculator and computer programming, or simply chat with like-minded coders and tech and calculator enthusiasts via the site-wide AJAX SAX widget? Registration for a free Cemetech account only takes a minute.

» Go to Registration page
Page 1 of 1
» All times are UTC - 5 Hours
 
You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot vote in polls in this forum

 

Advertisement