Skip to content

Latest commit

 

History

History
78 lines (71 loc) · 3.8 KB

README.md

File metadata and controls

78 lines (71 loc) · 3.8 KB

PetProjects

Arte et humanitate, labore et scientia PetProject

📌 Topics

This repository, PetProject, is a testament to my iOS development skills and technological prowess. It showcases the synergy of Swift, UIKit, SwiftUI, and other technologies in action as I craft elegant solutions to complex challenges. From sleek UI design to seamless data management, this repository reveals the artistry and innovation inherent in iOS development.

📌 My First Programm

The program demonstrates basic input/output operations, function definition and invocation, conditional statements, loops, type conversion, and random generation in Swift. It's a good starting point for learning to program in Swift and demonstrates the language's fundamental concepts.

//
//  main.swift
//  FirstApp
//
//  Created by Mustafa Bekirov on 18.04.2022.
//  Copyright © 2022 Mustafa Bekirov. All rights reserved.

import Foundation

print("Enter the first value")
// first value retrieval
var a = readLine()
print("Enter the second value")
// second value retrieval
var b = readLine()

let result = sum(a, b)
print("The result of adding is \(result)")

func sum(_ a: String?, _ b: String?) -> Int {
    return Int(a!)! + Int(b!)!
}
//_____________________________________________
// Random number
let randomNumber = UInt8.random(in: 1...250)
print("Enter a number option from 1 to 250 and press Enter")
// victory flag
var isWin = false
repeat {
    // attempt to convert the entered value to UInt8
    guard let userNumber = UInt8(readLine() ?? "") else {
        print("You have entered an incorrect number. Try again")
continue }
    // validation of the entered number
    if userNumber < randomNumber{
        print("Your option is less than the number given")
    } else if userNumber > randomNumber {
        print("Your option is greater than the mystery number")
    } else {
        print("You guessed it")
isWin = true }
} while !isWin

📌 License

This app is open-sourced software licensed under the MIT license.