Skip to content

Conversation

@halahaddad1
Copy link

Assignment Submission: Calculator

Congratulations! You're submitting your assignment. Please reflect on the assignment with these questions:

Reflection

Question Answer
What went well in your code style, such as indentation, spacing, variable names, readability, etc.? What was lacking?
I think the code is readable, I just need to get it to work properly
How did your code keep track of user input?
by creating the correct variables with the correct name
How did your code determine what operation to perform?
used different loops to determine what operation was appropriate
What opportunities exist to create small methods for this project?
method I felt were necessary were the main calculator method and a method for user input
In the next project, what would you change about your process? What would you keep doing?
I would try to make the code more precise and short

@CheezItMan
Copy link

Calculator

Major Learning Goals/Code Review

Criteria yes/no, and optionally any details/lines of code to reference
Correctly uses conditionals (if/else/elsif) ✔️
Correctly uses loops (while/until) ⚠ Take a look at my inline comments. Your loops to ensure things are integers don't work.
Correctly uses gets.chomp ✔️
Correctly uses variables ✔️
Correctly creates and uses custom methods ✔️

Functional Requirements

Functional Requirement yes/no
User can input two numbers and an operator and perform addition ✔️
User can input in two numbers and an operator and can perform subtraction ✔️
User gets feedback from the CLI when attempting to divide by zero, and the program does not give an error ✔️

Overall Feedback

Overall Feedback Criteria yes/no
Green (Meets/Exceeds Standards) 3+ in Code Review && 2+ in Functional Requirements ✔️

Code Style Bonus Awards

Was the code particularly impressive in code style for any of these reasons (or more...?)

Quality Yes?
Perfect Indentation ⚠ You have indentation issues here. See my inline comments.
Descriptive/Readable
Concise
Logical/Organized

Summary

Overall 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.

Comment on lines +8 to +10
4.times do |i|
puts "#{i+1}. #{arr[i]}"
end

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

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)

Choose a reason for hiding this comment

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

This doesn't work.

Suggested change
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

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","+"

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

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)

Choose a reason for hiding this comment

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

Suggested change
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!"

Choose a reason for hiding this comment

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

Suggested change
puts "wrong input! Please enter an Integer .. try again!"
puts "wrong input! Please enter an Integer .. try again!"
b = gets.chomp.to_i

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