Saturday, 31 October 2020

Swift - Method Overloading and init() methods programs


View Controller Class program




import UIKit


class ViewController: UIViewController {


    override func viewDidLoad() {

        super.viewDidLoad()

        

        //Creating instances to the class TenthStudent Class

        var mazeed = TenthStudent(stuName: "SK ABDUL MAZEED", telugu: 95, hindi: 98, english: 96, maths: 86, science: 90, social: 89)

        

        var asma = TenthStudent(stuName: "SK ASMA", telugu: 54, hindi: 52, english: 57, maths: 33, science: 38, social: 63)

        

        //Calling functions

        shahina()

        afeera()

        irfana()

        gulshan()

        

        

        // Do any additional setup after loading the view.

    }

    //Creating functions

    func shahina()

    {

        var name = "SHAIK SHAHINA"

        //Creating instances to the class InterStudent

        var shahina = InterStudent(stuName: name, sanskrit1: 98, english1: 98, maths1A: 75, maths1B: 75, physics1: 59, chemistry1: 60)

        shahina.interSecondYear(stuName: name, sanskrit2: 96, english2: 97, maths2A: 73, maths2B: 71, physics2: 57, chemistry2: 55, physicsLab: 29, chemistryLab: 30)

    }

    func afeera()

    {

        var name = "SHAIK AFEERA"

        //Creating instances to the class InterStudent

        var afeera = InterStudent(stuName: name, sanskrit1: 58, english1: 48, maths1A: 45, maths1B: 35, physics1: 29, chemistry1: 20)

        afeera.interSecondYear(stuName: name, sanskrit2: 56, english2: 47, maths2A: 33, maths2B: 31, physics2: 27, chemistry2: 25, physicsLab: 19, chemistryLab: 20)

        

    }

    func irfana()

    {

        var name = "SHAIK IRFANA"

        //Creating instances to the class BTechStudent

        var irfana = BTechStudent(stuName: name, engMarks: 82, CLangMarks: 65, maths1Marks: 72, maths2Marks: 56, phyMarks: 59, BEEMarks: 57, EDCMarks: 65, drawingMarks: 80)

        irfana.BTechSYFirstSem(stuName: name, UNIXMarks: 70, ADSMarks: 80, PSMarks: 65, DLDMarks: 78, MEFAMarks: 80, MFCSMarks: 66, UNIXLabMarks: 75, ADSLabMarks: 75)

        irfana.BTechSYSecondSem(stuName: name, ESMarks: 80, DBMSMarks: 69, COMarks: 77, SEMarks: 59, PPLMarks: 53, javaMarks: 55, DBMSLabMarks: 80, javaLabMarks: 80)

        irfana.BTechTYFirstSem(stuName: name, FLATMarks: 69, STMMarks: 73, CGMarks: 81, MPMCMarks: 87, DCSMarks: 93, DAAMarks: 79, MPMCLabMarks: 97, ACSLabMarks: 93)

        irfana.BTechTYSecondSem(stuName: name, OSMarks: 57, CDMarks: 66, CNMarks: 68, ISMarks: 78, AIMarks: 82, OOADMarks: 74, CNLabMarks: 84, OOADLabMarks: 88)

        irfana.BTechFinalFirstSem(stuName: name, NPMarks: 83, WTMMarks: 87, DWDMMarks: 89, ACAMarks: 81, MCMarks: 91, SPMMarks: 93, WTLabMarks: 88, NPLabMarks: 98)

        irfana.BTechFinalSecondSem(stuName: name, MSMarks: 96, ECMarks: 87, HCIMarks: 82, VIVAMarks: 93, minProjMarks: 49, projMarks: 195, seminarMarks: 47)

    }

    func gulshan()

    {

        var name = "SYED GULSHAN BANU"

        //Creating instances to the class BTechStudent

        var gulshan = BTechStudent(stuName: name, engMarks: 72, CLangMarks: 55, maths1Marks: 62, maths2Marks: 66, phyMarks: 39, BEEMarks: 67, EDCMarks: 75, drawingMarks: 70)

        gulshan.BTechSYFirstSem(stuName: name, UNIXMarks: 60, ADSMarks: 68, PSMarks: 55, DLDMarks: 58, MEFAMarks: 60, MFCSMarks: 46, UNIXLabMarks: 85, ADSLabMarks: 95)

        gulshan.BTechSYSecondSem(stuName: name, ESMarks: 77, DBMSMarks: 59, COMarks: 67, SEMarks: 79, PPLMarks: 73, javaMarks: 45, DBMSLabMarks: 50, javaLabMarks: 70)

        gulshan.BTechTYFirstSem(stuName: name, FLATMarks: 59, STMMarks: 33, CGMarks: 71, MPMCMarks: 77, DCSMarks: 63, DAAMarks: 69, MPMCLabMarks: 87, ACSLabMarks: 83)

        gulshan.BTechTYSecondSem(stuName: name, OSMarks: 77, CDMarks: 86, CNMarks: 88, ISMarks: 68, AIMarks: 87, OOADMarks: 84, CNLabMarks: 89, OOADLabMarks: 82)

        gulshan.BTechFinalFirstSem(stuName: name, NPMarks: 73, WTMMarks: 77, DWDMMarks: 79, ACAMarks: 61, MCMarks: 51, SPMMarks: 43, WTLabMarks: 78, NPLabMarks: 68)

        gulshan.BTechFinalSecondSem(stuName: name, MSMarks: 96, ECMarks: 77, HCIMarks: 92, VIVAMarks: 96, minProjMarks: 49, projMarks: 198, seminarMarks: 49)

    }

    



}


Class Files



import UIKit


class TenthStudent: NSObject {

    override init() {

        super.init()

    }

    //Creating init Method

    init(stuName: String, telugu: UInt8, hindi: UInt8, english: UInt8, maths: UInt8, science: UInt8, social: UInt8)

    {

            //Creating and storing the constants

            let passMarksTenth:UInt8 = 35

            let maxTotalTenth:UInt16 = 600

            print("\(stuName) Tenth Results")

            print("::::::::::::::::::::::::")


            //Calculating the total marks

            let totalMarks:UInt16 = UInt16(telugu) + UInt16(hindi) + UInt16(english) + UInt16(maths) + UInt16(science) + UInt16(social)

                

            //Calculating the percentage of marks

            let tenthPercentage:Float = (Float(totalMarks)*100)/Float(maxTotalTenth)

        

        //if conditon to check the overall result of student

        if (telugu >= passMarksTenth && hindi >= passMarksTenth && english >= passMarksTenth && maths >= passMarksTenth && science >= passMarksTenth && social >= passMarksTenth)

        {

            print("Congratulations! \(stuName) you have paseed in the examination")

            print("Total Marks  =   \(totalMarks)\nPercentage obtained by you is: \(tenthPercentage)")

            

          

        }else

        {

            print("Sorry! \(stuName) you have failed in the examination")

        }

        print("*********************************************************")

    }

}


InterStudent Class File

import UIKit


class InterStudent: NSObject {

    

    //Creating init method

    init(stuName: String, sanskrit1: UInt8, english1: UInt8, maths1A: UInt8, maths1B: UInt8, physics1: UInt8, chemistry1: UInt8)

    {

        //Creating and storing constants

        let passMarksMaths:UInt8 = 25

        let passMarksScience:UInt8 = 21

        let passMarksLanguages:UInt8 = 35

        let maxTotalFirst:UInt16 = 470

        //Calculating the inter first year total and percentage

        let interFirstTotal:UInt16 = UInt16(sanskrit1) + UInt16(english1) + UInt16(maths1A) + UInt16(maths1B) + UInt16(physics1) + UInt16(chemistry1)

        let interFirstPercentage:Float = (Float(interFirstTotal)*100)/Float(maxTotalFirst)

        print("<<<::    Intermediate First year results ::>>>")

        //Condition to check inter first year overall passed or failed

        if (sanskrit1 >= passMarksLanguages && english1 >= passMarksLanguages && maths1A >= passMarksMaths && maths1B >= passMarksMaths && physics1 >= passMarksScience && chemistry1 >= passMarksScience)

        {

            print("Congratulations! \(stuName) you are passed in the examination")

            print("Total Marks obtained is: \(interFirstTotal)")

            print("Percentage obtained by you is: \(interFirstPercentage)")

            

        }else

        {

            print("Sorry! \(stuName) you are failed in the examination")

        }

    

    }

    func interSecondYear(stuName: String, sanskrit2: UInt8, english2: UInt8, maths2A: UInt8, maths2B: UInt8, physics2: UInt8, chemistry2: UInt8, physicsLab: UInt8, chemistryLab: UInt8)

    {

        //Creating and storing constants

        let passMarksMaths:UInt8 = 25

        let passMarksScience:UInt8 = 21

        let passMarksLanguages:UInt8 = 35

        let maxTotalSecond:UInt16 = 530

        let passMarksLabs:UInt8 = 12

        

        //Calculating the inter Second year total and percentage

        let interSecondTotal:UInt16 = UInt16(sanskrit2) + UInt16(english2) + UInt16(maths2A) + UInt16(maths2B) + UInt16(physics2) + UInt16(chemistry2) + UInt16(physicsLab) + UInt16(chemistryLab)

        let interSecondPercentage:Float = (Float(interSecondTotal)*100)/Float(maxTotalSecond)

        print("<<<::    Intermediate Second year results ::>>>")

        //Condition to check inter Second year overall passed or failed

        if (sanskrit2 >= passMarksLanguages && english2 >= passMarksLanguages && maths2A >= passMarksMaths && maths2B >= passMarksMaths && physics2 >= passMarksScience && chemistry2 >= passMarksScience && physicsLab >= passMarksLabs && chemistry2 >= passMarksLabs)

        {

            print("Congratulations! \(stuName) you have passed in the examination")

            print("Total Marks obtained is: \(interSecondTotal)")

            print("Percentage obtained by you is: \(interSecondPercentage)")

            

        }else

        {

            print("Sorry! \(stuName) you are failed in the examination")

            

        }

        

    }


}



BTechStudent Class FIle

import UIKit


class BTechStudent: NSObject {

    

    init(stuName: String, engMarks: UInt8, CLangMarks: UInt8, maths1Marks: UInt8, maths2Marks: UInt8, phyMarks:UInt8, BEEMarks:UInt8, EDCMarks:UInt8, drawingMarks:UInt8)

    {

        //creating storing passmarks for Engineering subjects

        let passMarks:UInt8 = 40

        let maxTotal:Float = 800

        //Calculating the first year total and percentage

        let firstYearTotal:UInt16 = UInt16(engMarks) + UInt16(CLangMarks) + UInt16(maths1Marks) + UInt16(maths2Marks) + UInt16(phyMarks) + UInt16(BEEMarks) + UInt16(EDCMarks) + UInt16(drawingMarks)

        

        let firstYearPercentage:Float = (Float(firstYearTotal)*100)/Float(maxTotal)

        

        print("\(stuName) first year results \n-----------------------------")

        print("English\nC-Language\nMaths1\nMaths2\nPhysics\nBEE = Basic Electrical Engineering \nEDC = Electronic Devices and Circuits \nEngineering Drawing")

        

        //checking the condition overall first year passed or failed

        if (engMarks >= passMarks) && (CLangMarks >= passMarks) && (maths1Marks >= passMarks) && (maths2Marks >= passMarks) && (phyMarks >= passMarks) && (BEEMarks >= passMarks) && (EDCMarks >= passMarks) && (drawingMarks >= passMarks)

        {

            print("Congratulations! \(stuName) you have passed in the examination")

            print("your first year total marks is: \(firstYearTotal)")

            print("your first year percentage is: \(firstYearPercentage)")

            


        }else

        {

            print("Sorry! \(stuName) you have failed in the examination")

        }

    }

    //Creating a function for Btech Second year first sem result

    func BTechSYFirstSem(stuName: String, UNIXMarks:UInt8, ADSMarks:UInt8, PSMarks:UInt8, DLDMarks:UInt8, MEFAMarks:UInt8, MFCSMarks:UInt8, UNIXLabMarks:UInt8, ADSLabMarks:UInt8)

    {

        //creating storing passmarks for Engineering subjects

        let passMarks:UInt8 = 40

        let maxTotal:Float = 800

        //Calculating the second year first sem total and percentage

        let secondFirstSemTotal:UInt16 = UInt16(UNIXMarks) + UInt16(ADSMarks) + UInt16(PSMarks) + UInt16(DLDMarks) + UInt16(MEFAMarks) + UInt16(MFCSMarks) + UInt16(UNIXLabMarks) + UInt16(ADSLabMarks)

           

        let secondFirstSemPercentage:Float = (Float(secondFirstSemTotal)*100)/Float(maxTotal)

        print("\(stuName) Second year first sem results \n-----------------------------")

        print(" UNIX\nADS = Adavance Data Structures \nPS = Probability and Statistics \nDLD = Digital Logic Design \nMEFA = Managerial Economics and Financial Analysis\nMFCS = Mathematical Foundations and computer systems")

        //checking the condition overall first sem passed or failed

        if (UNIXMarks >= passMarks) && (ADSMarks >= passMarks) && (PSMarks >= passMarks) && (DLDMarks >= passMarks) && (MEFAMarks >= passMarks) && (MFCSMarks >= passMarks) && (UNIXLabMarks >= passMarks) && (ADSLabMarks >= passMarks)

        {

            print("Congratulations! \(stuName) you have passed in 2-1 semester examination")

            print("your  first semester total marks is: \(secondFirstSemTotal)")

            print("your  first semester percentage is: \(secondFirstSemPercentage)")

            


        }else

        {

            print("Sorry! \(stuName) you have failed in 2-1 semester examination")

        }

        print("________________________________________________________")

    }

    //Creating a function for Btech Second year Second sem result

    func BTechSYSecondSem(stuName: String, ESMarks:UInt8, DBMSMarks:UInt8, COMarks:UInt8, SEMarks:UInt8, PPLMarks:UInt8, javaMarks:UInt8, DBMSLabMarks:UInt8,  javaLabMarks:UInt8)

    {

        //creating storing passmarks for Engineering subjects

        let passMarks:UInt8 = 40

        let maxTotal:Float = 800

        

        print("\(stuName) Second year second sem results \n-----------------------------")

        print("ES = Environmental Studies \nDBMS = DataBase management Systems \nCO = Computer Organization \n SE = Software Engineering \nPPL = Principles of Programming Laguages \n Java")

        

        //Calculating the second year second sem total and percentage

        let secondSecondSemTotal:UInt16 = UInt16(ESMarks) + UInt16(DBMSMarks) + UInt16(COMarks) + UInt16(SEMarks) + UInt16(PPLMarks) + UInt16(javaMarks) + UInt16(DBMSLabMarks) + UInt16(javaLabMarks)

           

        let secondSecondSemPercentage:Float = (Float(secondSecondSemTotal)*100)/Float(maxTotal)

        

           //checking the condition overall second sem passed or failed

        if (ESMarks >= passMarks) && (DBMSMarks >= passMarks) && (COMarks >= passMarks) && (SEMarks >= passMarks) && (PPLMarks >= passMarks) && (javaMarks >= passMarks) && (DBMSLabMarks >= passMarks) && (javaLabMarks >= passMarks)

        {

            print("Congratulations! \(stuName) you have passed in the examination")

            print("your Second semester total marks is: \(secondSecondSemTotal)")

            print("your Second semester percentage is: \(secondSecondSemPercentage)")

            


        }else

        {

            print("Sorry! \(stuName) you have failed in the examination")

        }

        print("________________________________________________________")

    }

    //Creating a function for Btech Third year first sem result

    func BTechTYFirstSem(stuName: String, FLATMarks:UInt8, STMMarks:UInt8, CGMarks:UInt8, MPMCMarks:UInt8, DCSMarks:UInt8, DAAMarks:UInt8, MPMCLabMarks:UInt8, ACSLabMarks:UInt8)

    {

        //creating storing passmarks for Engineering subjects

        let passMarks:UInt8 = 40

        let maxTotal:Float = 800

        

        print("\(stuName) Third year first sem results \n-----------------------------")

        print("FLAT = Functional Language Automation Theory\nSTM = Software Testing Methodologies \nCG = Computer Graphics \nMPMC = Micro Processor and Micro Controllers \nDCS = Digital Communications \nDAA = Design Analysis and Algorithms")

        

        //Calculating the  first sem total and percentage

        let thirdFirstSemTotal:UInt16 = UInt16(FLATMarks) + UInt16(STMMarks) + UInt16(CGMarks) + UInt16(MPMCMarks) + UInt16(DAAMarks) + UInt16(DCSMarks) + UInt16(MPMCLabMarks) + UInt16(ACSLabMarks)

           

        let thirdFirstSemPercentage:Float = (Float(thirdFirstSemTotal)*100)/Float(maxTotal)

        

           //checking the condition overall first sem passed or failed

        if (FLATMarks >= passMarks) && (STMMarks >= passMarks) && (CGMarks >= passMarks) && (MPMCMarks >= passMarks) && (DAAMarks >= passMarks) && (DCSMarks >= passMarks) && (MPMCLabMarks >= passMarks) && (ACSLabMarks >= passMarks)

        {

            print("Congratulations! \(stuName) you have passed in the examination")

            print("your  first semester total marks is: \(thirdFirstSemTotal)")

            print("your  first semester percentage is: \(thirdFirstSemPercentage)")

            


        }else

        {

            print("Sorry! \(stuName) you have failed in the examination")

        }

        print("________________________________________________________")

    }

    //Creating a function for Btech Third year Second sem result

    func BTechTYSecondSem(stuName: String, OSMarks:UInt8, CDMarks:UInt8, CNMarks:UInt8, ISMarks:UInt8, AIMarks:UInt8, OOADMarks:UInt8, CNLabMarks:UInt8, OOADLabMarks:UInt8)

    {

        //creating storing passmarks for Engineering subjects

        let passMarks:UInt8 = 40

        let maxTotal:Float = 800

        

        print("\(stuName) Third year second sem results \n-----------------------------")

        print("OS = Operating Systems \nCD = Compiler Design \nCN = Compter Networks \nIS = Information Security \nAI = Aritficial Intelligence \nOOAD = Object Oriented Analysis and Design")

        

        //Calculating the second sem total and percentage

        let thirdSecondSemTotal:UInt16 = UInt16(OSMarks) + UInt16(CDMarks) + UInt16(CNMarks) + UInt16(ISMarks) + UInt16(AIMarks) + UInt16(OOADMarks) + UInt16(CNLabMarks) + UInt16(OOADLabMarks)

           

        let thirdSecondSemPercentage:Float = (Float(thirdSecondSemTotal)*100)/Float(maxTotal)

        

        //checking the condition overall second sem passed or failed

        if (OSMarks >= passMarks) && (CDMarks >= passMarks) && (CNMarks >= passMarks) && (ISMarks >= passMarks) && (AIMarks >= passMarks) && (OOADMarks >= passMarks) && (CNLabMarks >= passMarks) && (OOADLabMarks >= passMarks)

        {

            print("Congratulations! \(stuName) you have passed in the examination")

            print("your Second semester total marks is: \(thirdSecondSemTotal)")

            print("your Second semester percentage is: \(thirdSecondSemPercentage)")

            


        }else

        {

            print("Sorry! \(stuName) you have failed in the examination")

        }

        print("________________________________________________________")

    }

    //Creating a function for Btech Final year first sem result

    func BTechFinalFirstSem(stuName: String, NPMarks:UInt8, WTMMarks:UInt8, DWDMMarks:UInt8, ACAMarks:UInt8, MCMarks:UInt8, SPMMarks:UInt8, WTLabMarks:UInt8, NPLabMarks:UInt8)

    {

        //creating storing passmarks for Engineering subjects

        let passMarks:UInt8 = 40

        let maxTotal:Float = 800

        

        print("\(stuName) Final year first sem results \n-----------------------------")

        print("NP = Networkprogramming \nWTM = Web Technologies and Methods\nDWDM = Data Warehouse & Data Mining\nACA = Advance Computer Architecture\nMC = Mobile computing \nSPM = Software Project Management")

        

        //Calculating the first sem total and percentage

        let finalFirstSemTotal:UInt16 = UInt16(NPMarks) + UInt16(WTMMarks) + UInt16(DWDMMarks) + UInt16(ACAMarks) + UInt16(MCMarks) + UInt16(SPMMarks) + UInt16(WTLabMarks) + UInt16(NPLabMarks)

           

        let finalFirstSemPercentage:Float = (Float(finalFirstSemTotal)*100)/Float(maxTotal)

        

           //checking the condition overall first sem passed or failed

        if (NPMarks >= passMarks) && (WTMMarks >= passMarks) && (DWDMMarks >= passMarks) && (ACAMarks >= passMarks) && (MCMarks >= passMarks) && (SPMMarks >= passMarks) && (WTLabMarks >= passMarks) && (NPLabMarks >= passMarks)

        {

            print("Congratulations! \(stuName) you have passed in the examination")

            print("your  first semester total marks is: \(finalFirstSemTotal)")

            print("your  first semester percentage is: \(finalFirstSemPercentage)")

            


        }else

        {

            print("Sorry! \(stuName) you have failed in the examination")

        }

        print("________________________________________________________")


    }

    //Creating a function for Btech Final year Second sem result

    func BTechFinalSecondSem(stuName: String, MSMarks:UInt8, ECMarks:UInt8, HCIMarks:UInt8, VIVAMarks:UInt8, minProjMarks:UInt8, projMarks:UInt8, seminarMarks:UInt8)

    {

        //creating storing passmarks for Engineering subjects

        let passMarks:UInt8 = 40

        let finalSecondSemMaxTotal:UInt16 = 700

        

        print("\(stuName) Final year second sem results \n-----------------------------")

        print("MS = Mangaement Science \nEC = E-Commerce\nHCI = Human Computer Interaction")

        

        //Calculating the second sem year total

        let finalSecondSemTotal:UInt16 = UInt16(MSMarks) + UInt16(ECMarks) + UInt16(HCIMarks) + UInt16(VIVAMarks) + UInt16(minProjMarks) + UInt16(projMarks) + UInt16(seminarMarks)

           

        let finalSecondSemPercentage:Float = (Float(finalSecondSemTotal)*100)/Float(finalSecondSemMaxTotal)

        

           //checking the condition overall second sem passed or failed

        if (MSMarks >= passMarks) && (ECMarks >= passMarks) && (HCIMarks >= passMarks)

        {

            print("Congratulations! \(stuName) you have passed in the examination")

            print("your Second semester total marks is: \(finalSecondSemTotal)")

            print("your Second semester percentage is: \(finalSecondSemPercentage)")

            


        }else

        {

            print("Sorry! \(stuName) you have failed in the examination")

        }

        print("::::::::::**************************::::::::::::::::::::::")

    }


}


No comments:

Post a Comment