Hi all,

I've had my CG50 for a while now and wanted to start programming applications to help me out with a Geography project.

The program should take four inputs from the user, and then use a formula that uses all three with exponents and natural logarithms. But I can't find any documentation for this anywhere, and the parts I can find are either patchy, don't explain it enough for my novice mind, or both.

I'd really appreciate it if you could help me out so I can get the satisfaction of watching my project come to life - thanks in advance!
Have you written any programs in a BASIC-like language (or indeed, any language) before? What you're describing is the most basic type of calculator program, one that takes inputs, performs math on them, and then generates outputs. A few resources that might help:
  • WikiPrizm's list of BASIC commands (look at the left sidebar). You'll probably want the question mark command (gets input from the user) and the ln() command (just as you would use it from the homescreen).
  • To output something, you just need to put that text or number on a line by itself.

You can find the commands, including ?, by pressing [2nd][PRGM] from within the program editor, and the "->" below and in the Prizm wiki above is the button above AC/ON. The structure of the program you have in mind could be something like:
Code:
"INSTRUCTIONS HERE"
?->A
?->B
some math with A and B goes here->C
C
You can improve this a little bit with per-prompt instructions of what value you're requesting, e.g. (note the ? is outside the quotes):

Code:
"RADIUS"?->R
"HEIGHT"?->H
2πRH->V
"VOLUME"
V
You may also have used Python before - the CG50 has inbuilt support for (Micro)Python and includes a math module which should suit your needs. The Python editor is quite simple and should be easy to get into if you have used the language before. As an example,

Code:

import math
print(math.e ** int(input("A? ")) + math.log(int(input("B? "))))

Which will print (e to the power of A) + natural log of B
  
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