Final IOS
Final IOS
: 202203103520100
Practical 1
Aim: Introduction to Swift programming language and X Code IDE. Write
swift functions for following functionality.
Introduction to Swift:
Swift is a general-purpose programming language developed by Apple. It's used for
developing native iOS and macOS apps, as well as mobile and desktop apps, and cloud
services. Swift is also used for systems programming.
Introduction to Xcode:
Xcode is a free, integrated development environment (IDE) created by Apple for
developing software applications for Apple platforms like iPhones, iPad, MacBooks, etc. It
includes tools for writing, debugging, and testing software, as well as tools for managing
project files and resources. Every IDE consists of three parts: the editor, the debugger, and the
interface builder. The editor is the part where a programmer writes code. The debugger is the
part that informs a programmer of an error and helps him to rectify it. The interface builder is
the part where a programmer works on the visual elements of the app and integrates them with
the code.
Code:
import UIKit
var greeting = "Hello, playground"
var str = "202203103520100"
print(str)
func checkingPrimeNumber(num: Int) -> Bool{ if(num == 1 || num == 0){
return false
}
for j in 2..<num{
if (num % j == 0){ return false
}
}
return true
}
var lowerLimit = 1
var upperLimit = 20
print("Range-\(lowerLimit) to \(upperLimit)")
print("Prime numbers are :")
for k in lowerLimit...upperLimit{
if (checkingPrimeNumber(num: k)){ print(k)
}
}
Output:
Code:
import UIKit
Output:
Practical 2
Aim: Write a program to create parent class Person and derive two classes
from it namely Student and Employee. Classes shall have following
attributes and methods:
a. Person -> name, age, gender, city, get(), set()
var gsal:Double = 0
init()
{
super.init(name1:"Parimal", age1:20, gender1:"Male", city1:"Surat")
}
func grossalary() -> Double
{
if(sal<10000)
{
gsal = sal + (sal*0.15) + (sal*0.7) - 200
}
else
{
gsal = sal + (sal*0.15) + (sal*0.7) - (sal*0.10)
}
print("Salary:\(gsal)")
return gsal
}
}
var marko = Student()
marko.get()
marko.result()
var emp = Employee()
emp.get()
emp.grossalary()
Output:
P
ractical 3
Aim: Create an iOS application to develop “Say Hello App”. Use TextField
to get user name as input. On tap of button, display user name with
hello in Label.
Code:
import UIKit
print.text = name.text
super.viewDidLoad()
}
}
Output:
Extra Practical 3
Code:
//
// ViewController.swift
// odd
//
// Created by bmiit on 12/01/24.
//
import UIKit
class ViewController: UIViewController
let t=Int(t1.text!)!
if(t%2==0)
l2.text="Even"
else
l2.text="Odd"
super.viewDidLoad()
}
}
Output: