Skip to content
Permalink
3f236f1ecc
Switch branches/tags

Name already in use

A tag already exists with the provided branch name. Many Git commands accept both tag and branch names, so creating this branch may cause unexpected behavior. Are you sure you want to create this branch?
Go to file
 
 
Cannot retrieve contributors at this time
74 lines (51 sloc) 1.4 KB
import UIKit
//create an dictionary containing exercises and their calories
var exercises = [11:"Jumping Jacks", 12: "Jogging", 10: "Cycling", 5: "Squats", 9: "Skipping"]
var key = [11,12,10,5,9]
// Generate a workout that equals the target calorie
var user = 3000
var a = user/2
let b = a / 2
let c = b
let d = 0
//ARRAY OF ALL EXERCISES
var aList = [String]()
//EXERCISES AND REPS
var cycling1 = 0
var squats1 = 0
var skipping1 = 0
var jumpingJacks1 = 0
var jogging1 = 0
//CREATING A NEW WORKOUT PLAN
//DAY 1 -> CREATING A LIST OF ALL EXERCISES IN PLAN A
while (a >= 0) {
//generating a random key
var randKey = Int.random(in: 0..<5)
randKey = key[randKey]
//adding the random exercise onto new list
aList.append(exercises[randKey]!)
a = a - randKey
print(a)
}
for counter in 0...aList.count - 1{
let exercise = aList[counter]
switch exercise{
case "Cycling":
cycling1 += 1
case "Squats":
squats1 += 1
case "Skipping":
skipping1 += 1
case "Jumping Jacks":
jumpingJacks1 += 1
case "Jogging":
jogging1 += 1
default:
print("no exercise present")
}
}
print("Cycling FOR \(cycling1) MINS ")
print("Squats FOR \(squats1) MINS ")
print("Skipping FOR \(skipping1) MINS ")
print("Jumping Jacks FOR \(jumpingJacks1) MINS ")
print("Jogging FOR \(jogging1) MINS ")