Skip to content

Commit

Permalink
Revert "use double, check a"
Browse files Browse the repository at this point in the history
This reverts commit b01f77d.
  • Loading branch information
MrPaschenko committed Feb 8, 2022
1 parent b01f77d commit da19e8a
Showing 1 changed file with 9 additions and 27 deletions.
36 changes: 9 additions & 27 deletions Quadratic Equation Solver/main.swift
Original file line number Diff line number Diff line change
Expand Up @@ -12,37 +12,19 @@ var currentState = "Interactive"
print("Welcome to Quadratic Equation Solver!")

if (currentState == "Interactive") {
print("ax^2 + bx + c = 0")
print("Please, enter real numbers")

print("Please, choose numbers")
print("(ax^2 + bx + c = 0)")
print("a = ", terminator: "")
let a = Double(readLine()!) ?? 0
let a = Int(readLine()!) ?? 0

if a != 0 {
print("b = ", terminator: "")
let b = Int(readLine()!) ?? 0

print("c = ", terminator: "")
let c = Int(readLine()!) ?? 0

print("Equation is: \(a) x^2 + \(b) x + \(c) = 0")

} else {
print("Error, a != 0")
}
print("b = ", terminator: "")
let b = Int(readLine()!) ?? 0

print("c = ", terminator: "")
let c = Int(readLine()!) ?? 0
} else if (currentState == "Noninteractive") {

} else {
print("Error (currentState variable is incorrect)")
}

//func solveQuadraticEquation(a: Double, b: Double, c: Double) -> [Double] {
// let d = b * b - 4 * a * c
// if d > 0 {
// let x1 = (-b + sqrt(b * b - 4 * a * c)) / (2 * a)
// } else if d < 0 {
//
// } else if d == 0 {
//
// }
//}

0 comments on commit da19e8a

Please sign in to comment.