-
Notifications
You must be signed in to change notification settings - Fork 44
Calculator #43
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
base: master
Are you sure you want to change the base?
Calculator #43
Conversation
CalculatorWhat We're Looking For
|
puts "\nEnter the the first number:" | ||
a = gets.chomp | ||
while true | ||
if a.to_f.to_s == a || a.to_i.to_s == a |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Works great, but I'd encourage you to make a loop that repeats while the input is wrong and not infinitely and then break out when the input is valid. It just makes reading the code flow a little harder.
Also a
doesn't make a good variable name. The name doesn't tell anyone what the variable would be used for.
Lastly you also indented too much here. Indent by 1 tab or 2 spaces and be consistent.
end | ||
##### NOT SURE IF THIS SECTION IS NEEDED AT ALL, ESPECIALLY IF I HAVE CONVERTED THE USER INPUT INTO FLOAT/Integer.##### | ||
# change data types of number to float to account for decimal numbers. | ||
def num_class(i) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
If you want to avoid showing a decimal for integer math, then it's necessary.
|
||
# Get another number from the user. | ||
puts "Give me another number:" | ||
b = gets.chomp |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
More cryptic variable names noooooooo!!!
a = num_class(a) | ||
b = num_class(b) | ||
#### End of unworthy code which depend upon the previously written uworthy code#### | ||
# Case Loop |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
A case is not a loop, but a conditional like an if statement.
else puts "Please enter a number other than '0' when using division" | ||
end | ||
#Add support for the modulo operator (10 % 3 = 1). | ||
when '%' , 'modulo' |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
nice
Calculator
Congratulations! You're submitting your assignment.
Comprehension Questions