My task is to create an iOS application that will allow the user to enter the following information:
• First Name
• Last Name
• Age
The application will then display this information in a separate box as follows:
Hi firstName lastName, you are Message.
The Message will be replaced based on the age entered by the user as follows:
If age is < 12 Message => “a child”
If age is >= 13 and <= 19: Message => “a teenager”
If age is > 19 and <=29: Message => “a young man”
If age is >= 30 and <=49: Message => “a middle aged man”
If age is >= 50 and <=64: Message => “an experienced man”
If age is >= 65: Message => “a senior man”
import UIKit
class ViewController: UIViewController {
@IBOutlet weak var input1: UITextField!
@IBOutlet weak var input2: UITextField!
@IBOutlet weak var input3: UITextField!
@IBOutlet weak var output4: UILabel!
override func viewDidLoad() {
super.viewDidLoad()
// Do any additional setup after loading the view, typically from a nib.
}
override func didReceiveMemoryWarning() {
super.didReceiveMemoryWarning()
// Dispose of any resources that can be recreated.
}
@IBAction func buttonPressed(sender: UIButton) {
var one = input1.text.toInt()
var two = input2.text.toInt()
var three = input3.text.toInt()!
var total : String!
if sender.tag == 1{
if three < 12{
total = ("\(one) \(two) a child")
} else if three >= 13 && <=19 {
in the above line I get the error '<=' is not a prefix unary operator I tried giving space removing spaces but nothing works, the same error goes to the next else if statement too.. any help appreciated..
total = ("\(one) \(two) a teenager")
} else if three > 19 && <=29{
total = ("\(one) \(two) a young man")
} else if three >= 30 && <=49{
total = ("\(one) \(two) a middle aged man")
} else if three >= 50 && <=64{
total = ("\(one) \(two) an experienced man")
} else if three >= 65{
total = ("\(one) \(two) a senior man")
}
} else{
total = ("You are correct")
}
}
}
Can anyone help me resolving the occurring error?