Hi I’m trying to solve the following errors I wrote this code but to give the right result, I need to declare its values as Decimal to get the result, I did this test in the playground but it worked fine as in the image below but I can not pass it for my original project below is the image of the tests, the app and the code if anyone can help me thank you very much
// ViewController.swift
// Calculadora de Bitcoin
//
// Created by Tiago coelho de souza on 01/01/19.
// Copyright © 2019 tiago. All rights reserved.
//
import UIKit
class ViewController: UIViewController,UITextFieldDelegate {
@IBOutlet weak var btcResultado: UILabel!
@IBOutlet weak var valorTotal: UITextField!
@IBOutlet weak var valorInvestido: UITextField!
@IBAction func cacularSubtracao(_ sender: Any) {
if let valorT = valorTotal.text{
if let valorI = valorInvestido.text{
//validar numeros Digitados
let validaCampo = self.validarCampos(valorT: valorT, valorI: valorI)
if validaCampo {
if let valor1 = Float(valorT){
if let valor2 = Float(valorI){
let Resultado = Double(valor1 - valor2)
btcResultado.text = String(Resultado)
}
}
}else{
btcResultado.text = "Por Favor prencha os Campos"
}
}
}
}
func validarCampos(valorT:String,valorI:String) -> Bool{
var camposValidados = true
if valorT.isEmpty{
camposValidados = false
}else if valorI.isEmpty{
camposValidados = false
}
return camposValidados
}
override func viewDidLoad() {
super.viewDidLoad()
// Do any additional setup after loading the view, typically from a nib.
self.valorTotal.delegate = self
self.valorInvestido.delegate = self
}
override func touchesBegan(_ touches: Set<UITouch>, with event: UIEvent?) {
self.view.endEditing(true)
}
func textFieldShouldReturn(_ textField: UITextField) -> Bool {
textField.resignFirstResponder()
return(true)
}
}