Skip to content

Conversation

aruna79
Copy link

@aruna79 aruna79 commented Feb 8, 2018

Calculator

Congratulations! You're submitting your assignment.

Comprehension Questions

Question Answer
Describe how you stored user input in your program? I used three variables for storing the user inputs .Operation for the user choice of arithmetic operation and two variables num1 and num2 for the two numbers
How did you determine what operation to perform? Based on the user choice for the operation appropriate conditional if statement are executed
Do you feel like you used consistent indentation throughout your code? yes
If you had more time, what would you have added to or changed about the program? I would try to do the calculations using parenthesis

@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. Good consistent indentation
Extras You did exponents and modulus! Nice work!
Summary Nice catch on divide by zero! You hit all the requirements plus some extras. Nice job.


# Program for calculator.
puts " Welcome to the calculator "
operators_array = %w[add + subtract - divide / multiply * % ^]

Choose a reason for hiding this comment

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

nice


# To know when it needs to return an _integer_ versus a _float_.
def convert_i_f(value)
if (value =~ /\./)

Choose a reason for hiding this comment

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

This checks to see it if has ANY decimals in it. So the user could enter two of them, more detection of an invalid value would be better.

For example 3...1 is accepted

while flag
puts "Enter the first number "
num1 = gets.chomp
if (num1 =~ /[a-zA-Z]/)

Choose a reason for hiding this comment

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

This only checks for letters (a-z), not punctuation for example.

# To check whether the user input is numeric for second number
flag = true
flag = true
while flag

Choose a reason for hiding this comment

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

notice how this section is a repeat of above... great candidate for a 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