August 13, 2011

{Lessons} Lesson Number Five: Gratis Calculator!

Did you happen to know that Ruby has a free calculator? It can't do very complicated stuff, but it can do basic stuff, like addition and multiplication.


Addition
Just do a+b. To show the result, write a line like below:
print "19325325+123123247 is ",  19325325+123123247, ".\n" 
Subtraction
Just do a-b. To show the result, write a line like below:
print "19325325-123123247 is ",  19325325-123123247, ".\n" 
Multiplication
Just do a*b. To show the result, write a line like below:
print "19325325*123123247 is ",  19325325*123123247, ".\n" 
Division
Just do a/b. To show the result, write a line like below:
print "19325325/123123247 is ",  19325325/123123247, ".\n" 
Division with Remainder(Useful)
Just do a%b. To show the result, write a line like below: (Weird)
print "19325325%123123247 is ",  19325325%123123247, ".\n"
(You may want to change % to something like x divided by y is z.) 
XSquared
Just do a**b. To show the result, write a line like above:
print "19325325**123123247 is ",  19325325**123123247, ".\n" 
(You may not want to do this with such a big number)
P.S: Mind the space after the is or it will show up scrunched up.


SCREENSHOT:




















Lesson File: Mediafire


Sincerely yours, 
Admin

No comments:

Post a Comment

Free Website templatesFree Flash TemplatesRiad In FezFree joomla templatesSEO Web Design AgencyMusic Videos OnlineFree Wordpress Themes Templatesfreethemes4all.comFree Blog TemplatesLast NewsFree CMS TemplatesFree CSS TemplatesSoccer Videos OnlineFree Wordpress ThemesFree Web Templates