<commit_before>//
//  ViewController.swift
//  CarLoanCalculator
//
//  Created by <NAME> on 2014-08-08.
//  Copyright (c) 2014 Churowa. All rights reserved.
//

import UIKit

class ViewController: UIViewController {
    
//    let interestRate: Float = 1.0
//    
//    let interestPerPeriod = interestRate/100/12
//    
//    let numberOfPeriods = 60.0
//    
//    let originalPrincipal = 28498.0
//    
//    let numerator =  pow((1.0 + interestPerPeriod), numberOfPeriods)
//    let denominator = pow((1.0 + interestPerPeriod), numberOfPeriods)-1.0
//    
//    let paymentPerPeriod = originalPrincipal * interestPerPeriod * (numerator/denominator)
    
    @IBOutlet var numberOfMonths:UILabel!
    @IBOutlet var monthsSlider:UISlider!
    @IBOutlet var paymentText:UILabel!
    
    override func viewDidLoad() {
        super.viewDidLoad()
        numberOfMonths.text = "\(self.monthsSlider.value)"
        paymentText.text = "\(self.paymentPerPeriod(monthsSlider.value)) dollares"
        monthsSlider.addTarget(self, action: "valueChanged:", forControlEvents: UIControlEvents.ValueChanged)
    }

    func valueChanged(sender:UISlider) {
        numberOfMonths.text = "\(self.monthsSlider.value)"
        paymentText.text = "\(self.paymentPerPeriod(monthsSlider.value)) dollares"
    }
    
    override func didReceiveMemoryWarning() {
        super.didReceiveMemoryWarning()
        // Dispose of any resources that can be recreated.
    }
    
    func paymentPerPeriod(numberOfPeriods:Float) -> Float {
        let interestRate:Float = 1.0
        
        let interestPerPeriod:Float = interestRate/100/12
        let numPeriods:Float = numberOfPeriods
        
        let originalPrincipal:Float = 28498.0
        
        let numerator:Float =  pow((1.0 + interestPerPeriod), numPeriods)
        let denominator:Float = pow((1.0 + interestPerPeriod), numPeriods)-1.0

        return originalPrincipal * interestPerPeriod * (numerator/denominator)
    }


}

<commit_msg>Limit the UISlider's change events to only show integer month values.<commit_after>//
//  ViewController.swift
//  CarLoanCalculator
//
//  Created by <NAME> on 2014-08-08.
//  Copyright (c) 2014 Churowa. All rights reserved.
//

import UIKit

class ViewController: UIViewController {
    
//    let interestRate: Float = 1.0
//    
//    let interestPerPeriod = interestRate/100/12
//    
//    let numberOfPeriods = 60.0
//    
//    let originalPrincipal = 28498.0
//    
//    let numerator =  pow((1.0 + interestPerPeriod), numberOfPeriods)
//    let denominator = pow((1.0 + interestPerPeriod), numberOfPeriods)-1.0
//    
//    let paymentPerPeriod = originalPrincipal * interestPerPeriod * (numerator/denominator)
    
    @IBOutlet var numberOfMonths:UILabel!
    @IBOutlet var monthsSlider:UISlider!
    @IBOutlet var paymentText:UILabel!
    
    override func viewDidLoad() {
        super.viewDidLoad()
        numberOfMonths.text = "\(self.monthsSlider.value)"
        paymentText.text = "\(self.paymentPerPeriod(monthsSlider.value)) dollares"
        monthsSlider.addTarget(self, action: "valueChanged:", forControlEvents: UIControlEvents.ValueChanged)
    }

    func valueChanged(sender:UISlider) {
        let months = Int(self.monthsSlider.value)
        numberOfMonths.text = "\(months)"
        paymentText.text = "\(self.paymentPerPeriod(Float(months))) dollares"
    }
    
    override func didReceiveMemoryWarning() {
        super.didReceiveMemoryWarning()
        // Dispose of any resources that can be recreated.
    }
    
    func paymentPerPeriod(numberOfPeriods:Float) -> Float {
        let interestRate:Float = 1.0
        
        let interestPerPeriod:Float = interestRate/100/12
        let numPeriods:Float = numberOfPeriods
        
        let originalPrincipal:Float = 28498.0
        
        let numerator:Float =  pow((1.0 + interestPerPeriod), numPeriods)
        let denominator:Float = pow((1.0 + interestPerPeriod), numPeriods)-1.0

        return originalPrincipal * interestPerPeriod * (numerator/denominator)
    }


}


{'fraction_non_alphanumeric': 0.10689655172413794, 'fraction_numerical': 0.026108374384236452, 'mean_word_length': 2.742857142857143, 'pattern_counts': {'":': 0, '<': 5, '<?xml version=': 0, '>': 7, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '4820169', 'n_tokens_mistral': 1301, 'n_tokens_neox': 1214, 'n_words': 251}