Skip to content

Conversation

@seaweeddol
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 my indentation, spacing, variable names, and readability were all good. One thing I would have liked to do is make the code a little dryer.
How did your code keep track of user input? My code holds user input in three variables - the operator in one, and each number in two separate variables, which are received using gets.chomp
How did your code determine what operation to perform? My code uses a case to determine what operation to perform.
What opportunities exist to create small methods for this project? I used a method to validate that the user input was a valid number. I think I could have also implemented a method for the formula output - there was a lot of repetition here that probably could be reduced with a method.
In the next project, what would you change about your process? What would you keep doing? I might try to write pseudocode for the optional enhancements, as I had some trouble with these. For things I would keep doing, I would write the base program first and then work on the optional enhancements. I often try to jump right into the optional or complex parts of a project without doing the base project first, which can make things harder on myself. By starting with the base program first, I was able to focus on one thing at a time.

@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) ✔️
Correctly uses gets.chomp ✔️
Correctly uses variables ✔️
Correctly creates and uses custom methods ✔️, but I suggest moving method definitions to the top of the file. So they don't break up the flow of the main application.

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 ⚠ It works for / but not for modulo %

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 ⚠ Some indentation could be better (see inline comments).
Descriptive/Readable
Logical/Organized

Summary

Nice work, you hit the learning goals here. Well done. This makes a good start at Ada!

1 similar comment
@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) ✔️
Correctly uses gets.chomp ✔️
Correctly uses variables ✔️
Correctly creates and uses custom methods ✔️, but I suggest moving method definitions to the top of the file. So they don't break up the flow of the main application.

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 ⚠ It works for / but not for modulo %

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 ⚠ Some indentation could be better (see inline comments).
Descriptive/Readable
Logical/Organized

Summary

Nice work, you hit the learning goals here. Well done. This makes a good start at Ada!

end

# validate that user input is numeric
def validate_number(num)

Choose a reason for hiding this comment

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

I suggest moving your methods to the top of the file for now, later another file, and putting the main driver code below.


# update operator to operation to use in user prompt
case operator
when "add", "+", "1"

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.

formula += "#{num1} * "
end
puts "#{formula.chomp(" * ")} = #{num1.to_i ** num2.to_i}"
when "modulo"

Choose a reason for hiding this comment

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

You should also check for divide by 0 when using modulo.

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