Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Pipes - Sarah Read-Brown - Calculator #41

Open
wants to merge 2 commits into
base: master
Choose a base branch
from

Conversation

SRBusiness
Copy link

Calculator

Congratulations! You're submitting your assignment.

Comprehension Questions

Question Answer
Describe how you stored user input in your program. I stored the user number input into an array and the user operator into a variable as a string.
How did you determine what operation to perform? I created a method called calculator, a series of if/elsif statement, that matched the users operator input to my predefined operators.
How did you make sure your program behaved correctly? With each new feature I added I would go play with it pretty extensively in IRB. I entered a bunch of really strange or unexpected input along the way to see if I could break my code.
Do you feel like you used consistent indentation throughout your code? Yes I feel like I used consistent indentation in my code.
If you had more time, what would you have added to or changed about the program? If I had more time I would have liked to address the optional enhancement of having my program handle and out put both floats and integers appropriately.


def add(a, b)
return a + b
end
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I like that you've split these out into separate methods! It may seem a little pedantic for things like + and -, but for more complicated methods (for example checking for zero before doing division) it results in much cleaner code.

# loop to ensure the user input for the mathematical operator is valid
op = gets.chomp.to_s
until op_arr.include?(op)
puts "please enter a valid math operator"
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I like using until op_arr.include? to control this loop. Very easy to follow what's going on.

@droberts-sea
Copy link
Collaborator

Calculator

What We're Looking For

Feature Feedback
Takes in two numbers and an operator and performs the mathematical operation. Yes
Baseline
Readable code with consistent indentation. Yes

Great work overall!

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