Advertisement
hassanbanat

swift convert form C To F

Jan 6th, 2019
92
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Swift 0.38 KB | None | 0 0
  1. import Foundation
  2.  
  3. print ("1 from f to c")
  4. print ("2 from c to f")
  5.  
  6. var result = readLine()!
  7.  
  8.  
  9.  
  10. if (Int (result) == 1) {
  11.     var f = readLine()!
  12.  var c = 5.0/9.0 * (Double (f)! - 32)
  13.     print ("C:",c)
  14.    
  15.    
  16. }else if (Int (result) == 2){
  17.     var c = readLine()!
  18.    var f = 9.0/5.0 * Double (c)! + 32
  19.     print ("f:",f)
  20.  
  21. } else {
  22.     print ("please chose 1 or 2")
  23. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement