Java Conditional Logic Practice: Quadratic Equation Roots

Day 1 – Strengthening Core Java Problem Solving Today I practiced six conditional-logic problems in Java to improve clarity of thought and real-world decision making in code. Sharing one of them below — finding the roots of a quadratic equation using the discriminant (b² – 4ac). Key learnings: Used the discriminant to determine real, equal, or imaginary roots Applied an if–else–if chain to handle all possible cases cleanly Understood how mathematical logic translates directly into Java code Problem-solving reminder to myself: Good code comes from clear logic, not long syntax. I’ll share the remaining five problems in the comments for anyone who wants to explore the logic behind them. Thanks @Prasoon Bidua Sir for the guidance and emphasis on understanding fundamentals through practice. #Java #CoreJava #LearningInPublic #ConditionalStatements

  • No alternative text description for this image

Problem 2 – Electricity Bill Calculation Worked on slab-based billing using conditional logic: First 50 units → ₹0.50/unit Next 150 units → ₹0.75/unit Next 250 units → ₹1.20/unit Above 250 → ₹1.50/unit Added 20% surcharge at the end. This problem helped me think clearly about multi-level conditions and cumulative calculations.

  • No alternative text description for this image
Like
Reply

Problem 3 – Triangle Classification Based on the three sides entered, determined whether the triangle is: Equilateral (all sides equal) Isosceles (two sides equal) Scalene (all sides different) Good refresher on comparison logic.

  • No alternative text description for this image
Like
Reply

Problem 5 – Reverse Five-Digit Number & Palindrome Check Reversed the number using modulo and division, then compared it with the original. This improves control over mathematical operations and number manipulation.

  • No alternative text description for this image
Like
Reply

Problem 6 – Percentage to Division Calculated total marks → percentage → division using clean if–else blocks. A simple but good exercise in mapping numeric ranges to outcomes.

  • No alternative text description for this image
Like
Reply

Problem 4 – Character Classification Categorized input into: Alphabet Digit Special character Used character ranges to validate input — simple but essential for input handling.

  • No alternative text description for this image
Like
Reply
See more comments

To view or add a comment, sign in

Explore content categories