Created
April 28, 2009 14:12
-
-
Save NYiPhoneDeveloper/103179 to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| # Another program that I worked on for a few days. | |
| # I'm still a newbie - but I'm practicing my butt off! | |
| class Calculator | |
| print "put first value here: \n" | |
| val_1 = gets() | |
| val_1 = val_1.chomp.to_i | |
| print "Put second value here: \n" | |
| val_2 = gets() | |
| val_2 = val_2.chomp.to_i | |
| puts "These are your options: \n" \ | |
| + "To multiply put: 'm' \n" \ | |
| + "To divide put : 'd' \n" \ | |
| + "To add put : 'a' \n" \ | |
| + "To subtract put: 's' \n" | |
| option = gets() | |
| opt = option.chomp.to_s | |
| if opt == 'm' | |
| print "Value is: #{val_1 * val_2} \n" | |
| elsif opt == 'd' | |
| print "Value is: #{val_1 / val_2} \n" | |
| elsif opt == 'a' | |
| print "Value is: #{val_1 + val_2} \n" | |
| elsif opt == 's' | |
| print "Value is: #{val_1 - val_2} \n" | |
| else | |
| print "Value must be m, d, a, s" | |
| end | |
| end |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment