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

Calculator - Tanja Stroble #45

Open
wants to merge 1 commit into
base: master
Choose a base branch
from
Open

Conversation

misstonbon
Copy link

@misstonbon misstonbon commented Aug 11, 2017

Calculator

Congratulations! You're submitting your assignment.

Comprehension Questions

Question Answer
Describe how you stored user input in your program. I stored math operations the user chooses in a hash, words as keys and + - * / as values.
How did you determine what operation to perform? User provided either the word or symbol and the until loop was set up to control for acceptable input.
How did you make sure your program behaved correctly? Ran it in terminal and tried several different operations.This is where I found out that if denominator is greater than the numerator for fixnums, the result of a division is always zero, so I improved the program to set the result to float, allowing for 0.5345 and so on. Additionally, I tweaked the output a little bit. When result is an even float, i.e 4.0 , we don't really need the .0, so I fixed it so it displays just the relevant integer.
Do you feel like you used consistent indentation throughout your code? No. I constantly tweaked the program and commented things out as I went, so I used the ctrl+alt+l often both in order to get in the habit of fixing it often, and saving code often.
If you had more time, what would you have added to or changed about the program? I found how to do the parenthesis optional challenge on stack overflow, but was way too tired to keep going at 1 am.

@misstonbon misstonbon changed the title Add files via upload Calculator - Tanja Stroble Aug 11, 2017
@CheezItMan
Copy link

Calculator

What We're Looking For

Feature Feedback
Takes in two numbers and an operator and performs the mathematical operation. Check
Baseline
Readable code with consistent indentation. Check
Extras Handles parentheses and and combination of integers and floating point numbers.
Summary Nice work with the primary req and the extras. I like how you adjusted for whole and decimal numbers. Good work finding the eval method. Just be careful a eval can be a security vulnerability. You can read up on why here. You do also need to be careful of zero denominators in division. Also I would move methods and code outside of methods into different sections of the document. It just makes it easier to read.

Copy link

@CheezItMan CheezItMan left a comment

Choose a reason for hiding this comment

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

Just a note in your code.

return 0
elsif
num != 0
return num.include?(".") ? num.to_f : num.to_i

Choose a reason for hiding this comment

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

Nice work on adjusting for floating point numbers.

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