Quadratic Equation Java App

The formula to solve quadratic equations

The formula to solve quadratic equations

I’ve been solving a lot of quadratic formulas lately, and I grew tired of searching for web-based tools to solve them. I was not able to format the output of the answers either, so I decided to write a Java application that I could manipulate. I knew that I wanted to have real and imaginary answers that were good to 3 decimal places. That keeps my answers to a good precision. I wanted the output to look like: -0.707 + 0.707j, -0.707 – 0.707j!

(-b+SQRT(b^2-4ac))/(2a) and (-b-SQRT(b^2-4ac))/(2a). This is a simple formula, but doing it by hand more than once is tedious. This program was written in the time I was supposed to be solving pole-zero plots for my DSP class. I was done solving these problems when I decided I wanted my own program to solve them for me.

I have written a Java application that runs on your local computer.

For Windows users, simply download the .jar file and click it. It should run. I’ve tried it on XP with no issues. You may need the Java Runtime Environment. It can be downloaded from Sun for free.

For Linux/Ubuntu users, You’ll need to do a little work before you can use it. This is not a terminal program, but it can be opened easiest using the terminal until I figure out how to make it more user friendly. Download the .jar file. Open it with package manager and put the two class files in a folder where you can find them. I chose to put them on my desktop in a directory called QuadEquation. Extract the two class files into that folder. Then open a terminal and ‘cd /home/username/Desktop/QuadEquation’. Finally type ‘java QuadEquationTest.class’. The program will run like a champ, I hope.

Screen shots:

quadratic equation solve screen shotsQuadEquation : .jar (Java App)

The program also has a divide by zero protection. Dividing by zero is too much fun for this app, so it displays a prompt that alerts the user that it happened and then re-prompts for correct data. A final note, if you start the program, you’ll have to enter at least one equation to exit. (I like a=1, b=1.4142, c=1).

Good luck, and please let me know if you use it and like it. If you don’t like it, constructive criticism is the only form accepted.

About robbie

I am an electronics enthusiest and a ham radio operator (W1RCP). I like to play with electronics. It's fun and educational. I looked forward to working in the engineering field in the future. I have a BS in Electronics Engineering Technology from DeVry University. I also have an Associate's degree in Marketing Management from Moultrie Tech, and a diploma in Electronics from MTC.

4 thoughts on “Quadratic Equation Java App

  1. Hi how are doing? Can you please give me a tutorial on how to that or similor to that one? for my school project, i have to write a GUI application that solve quadratic equation (in java netbeans)

  2. I’m sorry that I cannot provide assistance in writing Java programs. I would start with a simple terminal Java program to get functionality. After you solve the problem, then you can add the GUI functions. Java is too broad for me to explain how to write the program.

  3. i know how to make a gui interface..like for example i 3 textfields for inputs by user, a solve button and two other textfields to display the roots…nw the problem i have is making the solve button work so that it soves the equation.

Comments are closed.