Skip to content

MrPaschenko/quadratic-equation-solver

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

17 Commits
 
 
 
 
 
 

Repository files navigation

Quadratic Equation Solver

This is lab 1 for Software Development Methodologies and Technologies

This tiny CLI program written in Swift lets you solve quadratic equations

Installation

  1. Be sure that you have installed Git to clone the repository and Swift to run script

  2. Clone the repository to you local machine

git clone https://github.com/MrPaschenko/quadratic-equation-solver
  1. Open directory
cd quadratic-equation-solver/Quadratic\ Equation\ Solver
  1. Run script
swift main.swift

Usage

There are two modes supported:

  1. Interactive
  2. Noninteractive
Welcome to Quadratic Equation Solver!
Choose mode:
Interactive (1) or Noninteractive (2)

1. Interactive

Just enter real numbers for a, b, c variables and script will solve the problem!

>1
You chose Interactive mode
ax^2 + bx + c = 0
Please, enter real numbers
> a = 2
> b = 1
> c = -3
Equation is: (2.0) x^2 + (1.0) x + (-3.0) = 0
Discriminant is 25.0
There are 2 roots
x1 = 1.0
x2 = -1.5

2. Noninteractive

Enter path to file to solve the problem

>2
You chose Noninteractive mode
Please, enter path to file
> Documents/file.txt
Equation is: (1.0) x^2 + (0.0) x + (0.0) = 0
Discriminant is 0.0
There is 1 root
x = -0.0

File's content should be as follows:

1 0 0

or

1\s0\s0\n

Revert commit

About

✖️ CLI Quadratic Equation Solver

Resources

Stars

Watchers

Forks

Languages