-
Notifications
You must be signed in to change notification settings - Fork 49
Create calculator.rb #47
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?
Conversation
CalculatorMajor Learning Goals/Code Review
Functional Requirements
Overall Feedback
Code Style Bonus AwardsWas the code particularly impressive in code style for any of these reasons (or more...?)
SummaryOverall there's some good work here. You hit the learning goals. This makes a good start at Ada. One thing I strongly suggest is that you run the code and test things a few times before submission. You would have caught your errors in the input validation then. |
| 4.times do |i| | ||
| puts "#{i+1}. #{arr[i]}" | ||
| end |
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.
Indentation is needed here.
| options = ["add", "+","subtract","-","multiply","*","divide","/"] | ||
| if !options.include?(x) | ||
| puts "wrong input! try again!" | ||
| x = 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.
indentation
|
|
||
| puts "what numbers would you like to calculate" | ||
| a= gets.chomp.to_i | ||
| while !options.include?(a==Integer) |
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.
This doesn't work.
| while !options.include?(a==Integer) | |
| while a != a.to_s.to_i |
|
|
||
|
|
||
| puts "what numbers would you like to calculate" | ||
| a= gets.chomp.to_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.
Don't use variable names like a. Instead use meaningful variable names like first_num
|
|
||
| def operator(m,n,y) | ||
| case y | ||
| when "add","+" |
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.
The when should be indented under the case.
| end | ||
|
|
||
| def operator(m,n,y) | ||
| case y |
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.
The case should be indented under the method here.
| a=gets.chomp.to_i | ||
| end | ||
| b= gets.chomp.to_i | ||
| while !options.include?(b==Integer) |
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.
| while !options.include?(b==Integer) | |
| b != b.to_s.to_i``` |
| end | ||
| b= gets.chomp.to_i | ||
| while !options.include?(b==Integer) | ||
| puts "wrong input! Please enter an Integer .. try again!" |
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.
| puts "wrong input! Please enter an Integer .. try again!" | |
| puts "wrong input! Please enter an Integer .. try again!" | |
| b = gets.chomp.to_i |
Assignment Submission: Calculator
Congratulations! You're submitting your assignment. Please reflect on the assignment with these questions:
Reflection