Skip to content

Comments

Create Katherine Fitzpatrick calculator.rb#24

Open
KatherineJF wants to merge 1 commit intoAda-C10:masterfrom
KatherineJF:master
Open

Create Katherine Fitzpatrick calculator.rb#24
KatherineJF wants to merge 1 commit intoAda-C10:masterfrom
KatherineJF:master

Conversation

@KatherineJF
Copy link

Calculator

Congratulations! You're submitting your assignment.

Comprehension Questions

Question Answer
Describe how you stored user input in your program? I prompted the user for the first and then the second number then stored them in two different variables
How did you determine what operation to perform? I used elsif statements to to identify if the user inputed a symbol OR a word to describe the operation.
Do you feel like you used consistent indentation throughout your code? I yes
If you had more time, what would you have added to or changed about the program? If I had more time I would have used regexp to identify floats when I check to see if user input is a valid to create logic specifically for division which isn't calculating accurately.


puts "Welcome to the Calculator program! Which operator would you like to use? \n\

1. add(+)

Choose a reason for hiding this comment

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

This block gets printed twice to start

end

def mod(number,other)
return number.to_f % other.to_f

Choose a reason for hiding this comment

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

No check to prevent me from % by zero!

end

def addnum(number,other)
return number.to_i + other.to_i

Choose a reason for hiding this comment

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

Watch indentation!


if command == "+" || command == "add"
result = addnum(number,other)
puts "the answer is " + " " + "#{result}"

Choose a reason for hiding this comment

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

Watch indentation!


elsif command == "%" || command == "modulo"
result = mod(number,other)
puts "the answer is " + " " + "#{result}"

Choose a reason for hiding this comment

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

indentation!

4. divide (/)
5. modulo (%)
6. exponent (**)"
command = gets.chomp

Choose a reason for hiding this comment

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

Gah Indentation!

@CheezItMan
Copy link

Calculator

What We're Looking For

Feature Feedback
Takes in two numbers and an operator and performs the mathematical operation. Check
Readable code with consistent indentation. Doh You have misaligned stuff
Summary You hit the major learning goals, some issues with formatting and text printed twice.

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