SarthakKeshari / calc_for_everything

This repository aims to provide Calculators for educational, professional, scientific, health and well-being and other purposes.
https://calc-for-everything-psi.vercel.app
MIT License
115 stars 103 forks source link

diamondProblemSolver #612

Closed Alfred-hhy closed 8 months ago

Alfred-hhy commented 8 months ago

Issue Id: #591

Briefly explain your program logic: This React component is a Diamond Problem Solver. It takes two factors as input, calculates their product and sum, and displays the results. The calculations are updated whenever the input factors change. It also includes basic input validation.

Screenshots: image image

By raising this PR I affirm that -

SarthakKeshari commented 8 months ago

@Alfred-hhy, Kindly re-read the calculation functionality description in the issue

Alfred-hhy commented 8 months ago

@SarthakKeshari Please review the modified pull request once again. Issue Id: #612

Briefly explain your program logic:

  1. State Variables: The component uses the useState hook to manage state variables for a, b, product, sum, equationSteps, and calculateButtonClicked.
  2. Input Validation: The isInteger function checks if a given value is an integer using a regular expression.
  3. Effect Hook: The useEffect hook is used to calculate values and update equation steps whenever there is a change in the state variables (a, b, product, sum, calculateButtonClicked).
  4. Input Change Handling: The handleInputChange function is triggered on input changes. It updates the state variables based on the input type (a, b, product, sum). It also recalculates sum and product based on valid inputs.
  5. Calculation Functions: The calculateValues function performs calculations based on the input values, updating the state variables and equation steps accordingly. It covers various scenarios to solve the Diamond Problem.
  6. Button Click Handling: The handleCalculate function sets calculateButtonClicked to true, triggering the recalculation in the useEffect hook.
  7. Equation Solving: The findNumbers function calculates values for a and b given the product and sum. It uses the quadratic formula and updates the equation steps.
  8. Rendering: The component renders a UI with Material-UI components, including text fields for input, buttons to trigger actions, and a display of equation steps.

Screenshots: image image

By raising this PR I affirm that -

SarthakKeshari commented 8 months ago

@Alfred-hhy, Kindly revert all package-lock.json and push the code again

Alfred-hhy commented 8 months ago

"Sure, I'll revert the package-lock.json and push the code again. Will keep you posted once it's done!"

Alfred-hhy commented 8 months ago

@SarthakKeshari I have'already revert all package-lock.json.

SarthakKeshari commented 8 months ago

@Alfred-hhy, Good work. I can find the PR updated now.

Thankyou

Alfred-hhy commented 8 months ago

@SarthakKeshari , I also recently started contributing to GitHub by making pull requests. Thank you for assigning tasks to me, responding quickly, and being understanding of the mistakes I made earlier.

Sincerely grateful.

SarthakKeshari commented 8 months ago

Congratulations 🎉 @Alfred-hhy on your contribution. Thanks for adding value to this repository. 😊

Let's celebrate this fest 😃 by providing more developers 👨‍💻👩‍💻 an opportunity to contribute. Help us make this repository reach far and more by sharing this to your friends and colleagues.

Your efforts can make difference.

SarthakKeshari commented 8 months ago

Hey 👋, may you also encourage us by clicking the star icon on the repository main page. ⭐

image

Alfred-hhy commented 8 months ago

@SarthakKeshari 🎉 Thank you so much for the warm congratulations! I'm thrilled to be a part of this project and contribute to its growth. 😊

Absolutely, 🚀 I've already shared it with my friends and colleagues, and I'll continue to do so.

And of course, ⭐️ clicked! Your encouragement means a lot. 💪👨‍💻👩‍💻

SarthakKeshari commented 8 months ago

@Alfred-hhy, Thank you so much.