Skip to content

Lynn Trickey's Calculator#33

Open
ltrickey wants to merge 2 commits intoAda-C7:masterfrom
ltrickey:master
Open

Lynn Trickey's Calculator#33
ltrickey wants to merge 2 commits intoAda-C7:masterfrom
ltrickey:master

Conversation

@ltrickey
Copy link

Calculator

Congratulations! You're submitting your assignment.

Comprehension Questions

Question Answer
Describe how you stored user input in your program? **Please use calculator_edit! Couldn't figure out how to delete the first one... ** I stored user input in different variables - command, input_one, input_two
How did you determine what operation to perform? using a case statement (woo!) I matched the user input stored in the variable command with a bunch of possibilities - plus, +, add, addition, and if it fulfilled any of those, I matched it to the appropriate operation - addition.
Do you feel like you used consistent indentation throughout your code? I think so!
If you had more time, what would you have added to or changed about the program? I would have liked to work on making sure that the user is entering ONLY numbers when prompted. Right now the program will take an input such as "butts1234" and it will pass the challenge of "is this a number?" because using the regrex it only checks to see if it has any numbers at all. But then I turn that whole string into a float, using .to_f, so it would interpret that as 0. I know I could search for integers and pull them out and I'd like to do that.

@ltrickey ltrickey closed this Feb 10, 2017
@ltrickey ltrickey reopened this Feb 10, 2017
@kariabancroft
Copy link

Calculator

What We're Looking For

Feature Feedback                                                                              
Takes in two numbers and an operator and performs the mathematical operation. Done
Baseline
Readable code with consistent indentation. Done, with comments at each major section of code. Nice

Summary

Good use of the case statement to determine which operation to perform. You could also have used a hash like this:

operations = { "add" => "+", "+" => "+", "subtract" => "-", "-" => "-", "multiply" => "*", "*" => "*", "divide" => "/", "/" => "/" }
command = operations[command]

So then if they had entered "add" or "+" command would become "+", etc. However what you did worked perfectly well. That's just another approach. I like how you incorporated a method to do the calculations. You could probably do something similar to do the reading in of user input. I also like how you used the array to verify the proper operation. Very slick.

Overall a very nice submission.

Reviewed by Chris

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants