Skip to content

Pushpa -Edges-calculator.rb#28

Open
pushpaagr wants to merge 2 commits intoAda-C10:masterfrom
pushpaagr:master
Open

Pushpa -Edges-calculator.rb#28
pushpaagr wants to merge 2 commits intoAda-C10:masterfrom
pushpaagr:master

Conversation

@pushpaagr
Copy link

Calculator

Congratulations! You're submitting your assignment.

Comprehension Questions

Question Answer
Describe how you stored user input in your program? I stored user input in my program using variables, and using gets.chomp method to get the information from the user.
How did you determine what operation to perform? I determined what operation to perform by using if/else statement and using while loop.
Do you feel like you used consistent indentation throughout your code? yes, I used consistent indentation throughout my code.
If you had more time, what would you have added to or changed about the program? If I had more time I would change my code to allow for user to input strings and have my program respond to that.

@droberts-sea
Copy link

Calculator

What We're Looking For

Feature Feedback
Takes in two numbers and an operator and performs the mathematical operation. yes
Readable code with consistent indentation. mostly - see inline

You didn't use methods at all in this implementation. The code works the way it's supposed to, but working with methods is one of the core learning goals of this assignment, and I'm worried that you missed this opportunity to practice them. As you work on the data transformation worksheet and RideShare, please make sure you're wrapping each piece of work in its own method.

Other than that, this submission looks good. There are a few places where things could be cleaned up that I've tried to outline below, but in general I'm happy with the code you've written. Keep up the hard work!

calculator.rb Outdated
num2 = gets.chomp.to_f
end
answer = num1 / num2
else

Choose a reason for hiding this comment

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

Watch your indentation here.

calculator.rb Outdated
while num2 <= 0
puts "please enter a different number for your 2nd number, as it has to be greater than 0"
num2 = gets.chomp.to_f
end

Choose a reason for hiding this comment

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

Dividing by something less than 0 is fine, it's only dividing by 0 itself that is a problem.

calculator.rb Outdated
else
puts "please only pick from following operators\n 1. add(+)\n 2. subtract(-)\n 3. multiply(*)\n 4. divide(/)"
operator = gets.chomp
end

Choose a reason for hiding this comment

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

Here you ask the user for another operator, but you don't use that information. The if statement ends, and you ask whether the user wants to play again, and then they need to choose another operator.

calculator.rb Outdated
puts "pick 1st number"
num1 = gets.chomp.to_f

puts "pick 2nd number"

Choose a reason for hiding this comment

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

This code to pick two numbers is repeated many times. Could you DRY this up? You could either write a method, or move the number picking outside the if statement.

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