Academic Integrity: tutoring, explanations, and feedback — we don’t complete graded work or submit on a student’s behalf.

Create the code in Swift Xcode for a native application code in Swift Xcode for

ID: 3917455 • Letter: C

Question

Create the code in Swift Xcode for a native application code in Swift Xcode for iPhone or iPad (or Universal) that tests the user knowledge of a certain topic.

Your application should have at least 10 questions hard-coded and each time the user starts the application, 5 of these questions are selected randomly.

For every question, user should select one option out of four options presented.

When the user answers the fifth question, the application should display the user’s score and one of the following messages depending on their score.

The topic for the questions should be chosen carefully and all the questions should be meaningful. All the questions should be based on the topic you havechosen.

If the score of the test is Option 1 (see above) user should be given an option to retake the quiz.

Explanation / Answer

override func viewDidLoad() {

super.viewDidLoad()

questionArray = generateRandomNumber(0...<5)

int rightanswers=0;

int numberOfQuestions=0;

}

override func viewDidAppear(_ animated: Bool) {

newQuestion()

}

// Quiz//

print("Computer Hardware");

var questions: [Question] = [

Question(

question 1: "From what location are the 1st computer instructions available on boot up??",

answers: ["ROM BIOS", "CPU", "boot.ini", "config.sys"],

correctAnswer: 0),

Question(

question 2: "What could cause a fixed disk error.?",

answers: ["No-CD installed", "bad ram", "slow processor", "Incorrect CMOS settings"],

correctAnswer: 3),

Question(

question 3: "Missing slot covers on a computer can cause?",

answers: ["over heat", "power surges", "EMI", "incomplete path for ESD"],

correctAnswer: 0),

Question(

question 4: "When installing PCI NICS you can check the IRQ availability by looking at?",

answers: ["dip switches", "CONFIG.SYS", "jumper settings", "motherboard BIOS"],

correctAnswer: 3)

Question(

question 5: "With respect to a network interface card, the term 10/100 refers to?",

answers: ["protocol speed", "a fiber speed", "megabits per seconds", "minimum and maximum server speed"],

correctAnswer: 2)

Question(

question 6: "Which Motherboard form factor uses one 20 pin connector?",

answers: ["ATX", "AT", "BABY AT", "All of the above"],

correctAnswer: 0)

Question(

question 7: "A hard disk is divided into tracks which are further subdivided into:?",

answers: ["clusters", "sectors", "vectors", "heads"],

correctAnswer: 1)

Question(

question 8: "A wrist grounding strap contains which of the following:?",

answers: ["Surge protector", "Capacitor", "Voltmeter", "Resistor"],

correctAnswer: 3)

Question(

question 9: "Which standard govern parallel communications??",

answers: ["RS232", "RS-232a", "CAT 5", "IEEE 1284"],

correctAnswer: 3)

Question(

question 10: "In laser printer technology, what happens during the conditioning stage?",

answers: ["The corona wire places a uniform positive charge on the paper", "A uniform negative charge is placed on the photosensitive drum",

"A uniform negative charge is placed on the toner", "All of the above"],

correctAnswer: 1)

]

//Variables

var currentQuestion = 0

var rightAnswerPlacement:UInt32 = 0

var questionArray: [Int] = [] // Just an initial value

//Generate Random Numbers

func generateRandomNumber(_ from:Int, _ to:Int, _ qut:Int?) -> [Int] {

var myRandomNumbers = [Int]() //All our generated numbers

var numberOfNumbers = qut //How many numbers to generate

let lower = UInt32(from) //Generate from this number..

let higher = UInt32(to+1) //To this one

if numberOfNumbers == nil || numberOfNumbers! > (to-from) + 1 {

numberOfNumbers = (to-from) + 1

}

while myRandomNumbers.count != numberOfNumbers {

let myNumber = arc4random_uniform(higher - lower) + lower

if !myRandomNumbers.contains(Int(myNumber)) {

myRandomNumbers.append(Int(myNumber))

}

}

return myRandomNumbers

}

//Label

@IBOutlet weak var lbl: UILabel!

//Button

@IBAction func action(_ sender: AnyObject) {

if (sender.tag == Int(rightAnswerPlacement)) {

rightanswers=rightanswers+1;

} else{}

if (numberOfQuestions!=5) {

newQuestion()

numberOfQuestions++;

}

else {

if(rightanswers<3)

{

print("Try Again");

}

else if(rightanswers=3)

{

print("Good Job!");

}

else if(rightanswers=4)

{

print("Excellent Work!");

}

else()

{

print("you are a genius!");

}

}

}

//Function that displays new question

func newQuestion() {

lbl.text = questions[questionArray[currentQuestion]]

rightAnswerPlacement = arc4random_uniform(3)+1

//Create a button

var button:UIButton = UIButton()

var x = 1

for i in 1...5{

//Create a button

button = view.viewWithTag(i) as! UIButton

if (i == Int(rightAnswerPlacement)) {

button.setTitle(answers[questionArray[currentQuestion]][0], for: .normal)

} else {

button.setTitle(answers[questionArray[currentQuestion]][x], for: .normal)

x = 2

}

}

currentQuestion += 1

}

Hire Me For All Your Tutoring Needs
Integrity-first tutoring: clear explanations, guidance, and feedback.
Drop an Email at
drjack9650@gmail.com
Chat Now And Get Quote