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

Lauren C calculator.rb #48

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

Conversation

enigmagnetic
Copy link

Calculator

Congratulations! You're submitting your assignment.

Comprehension Questions

Question Answer
Describe how you stored user input in your program. I passed the user input to methods to verify, then assigned the verified input to three variables: operator, num_1, and num_2.
How did you determine what operation to perform? In the validate_operator method, I use a loop to get valid keywords or symbols, then used a case statement to assign the correct symbol back to the operator variable. In the calculate method, I used another case statement to computer the two numbers based on the string in the operator variable.
How did you make sure your program behaved correctly? I tested by inputting incorrect strings (non-operators or mixed alpha-numeric characters) multiple times, then trying out different types of numbers and operators. I found a typo that prevented the division equation from running, and it took me quite a while to figure out how to get the input error message to keep repeating instead of just accepting the second value (and converting it to 0).
Do you feel like you used consistent indentation throughout your code? Not entirely. I need to check the style guide for case when statements.
If you had more time, what would you have added to or changed about the program? The ability to check for other invalid characters in the numbers, to handle parentheses, and to handle division by 0 errors.

@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 Prevented erroneous input on numbers and operators. Handles exponentiation as well.
Summary Nice work you hit all the requirements. One bug is when the user enters 0 for a denominator, which of course generates a divide by zero error.

num_1 = valid_num(gets.chomp)

puts "Second number:"
num_2 = valid_num(gets.chomp)

Choose a reason for hiding this comment

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

Why pass gets.chomp as an argument? Why not simply include that in the method.

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