The Kotlin CLI app to solve quadratic equations
View the code here.
This application is designed to solve quadratic equations of the form
-
Interactive mode - the application asks the user to enter the coefficients of the equation and prints the roots.
-
Non-interactive mode - the application takes the coefficients from input TXT-file argument and prints the roots.
-
Download Kotlin compiler here
-
Extract the archive on your computer
-
Add the Kotlin bin folder to your system's PATH environment variable. Open the command prompt (CMD) and run the following command:
setx /M PATH "%PATH%;C:\path\to\kotlin\bin"- Replace "C:\path\to\kotlin" with the path to the folder where you extracted the Kotlin compiler.
NOTE: You can add Kotlin bin folder to your system's PATH environment variable using Windows UI tools. Click here to see the instructions.
- Verify that the Kotlin compiler is installed correctly by running the following command in the command prompt:
kotlinc -version- Verify that you have Java Runtime Environment(JRE) on your computer
- Clone the project on your computer.
git clone https://github.com/AKushch1337/SDMaT-lab1-
Move into the folder where you cloned the project
-
Open the command prompt (CMD) and run the following command:
kotlinc *.kt -include-runtime -d quadratic-equation-solver-cli.jarNOTE: You can replace
quadratic-equation-solver-cliwith whatever name you want
- This will generate .jar file which you can run using Java Runtime Environment(JRE)
NOTE: You can skip the "Build the project" part and just download the .jar file =)
- Download here.
java -jar \path\to\runtime\file\quadratic-equation-solver-cli.jarjava -jar \path\to\runtime\file\quadratic-equation-solver-cli.jar \path\to\file\with\inputsWhen the application is in non-interactive mode it expects a single argument that specifies the path to the file containing the coefficients of the equation. The file should have three numbers separated by a single space, representing the coefficients a, b, and c of the equation. Here's an example of how the numbers should be formatted in the file.