LAST CHANCE: Save 50% on all my Swift books and bundles! >>

checkpoint 1: just want to make sure my logic is correct.

Forums > 100 Days of SwiftUI

let c = 25.0
let f = Int(c) * 9 / 5 + 32
print("Celsisus: \(c)° + Fahrenheit: \(f)° "

I created a contsant for holding 25.0 the temp in celsius. I then created another contsant for holding the converted celsius to fahrenheit. Lastly printed the values respectively.

Thank you!


Welcome to HackingWithSwift forums.

+1 for formatted code!

Here are some comments I might share with a junior developer during a code review.

  1. Why do you define c as a Double, but f is in Integer ? This seems inconsistent.
  2. Consider using full words for your variables instead of c and f.
  3. Because f is an integer, you may be losing accuracy when you convert c and do maths. Are you ok with losing accuracy?
  4. Your print statement is incomplete. Missing a closing parenthesis. This may be cut/paste error.
  5. Consider replacing the + sign with an = sign in your print statement. Also, chak ur spalling.
  6. +1 for including degree symbols! Nice touch.

About variable names.

But wait, you say, c and f are common abbreviations for centigrade and fahrenheit. In this case, not a big deal. But many development teams might ask you to consider full word names for your variables. If you have a long name such as temperatureInCelsius, that's a lot to type compared with a simple "c". XCode is great in this regard, because your variables will benefit from code completion. But future you will thank past you for being more verbose. YMMV.

Keep asking questions!

Also take a few moments to read many of the older posts. There are some great nuggets in older messages.


let celsius = 25.0
let fahrenheit = celsius * 9 / 5 + 32
print("The current temperature is \(celsius)°C =  \(fahrenheit)°F.")

Thank you for the feedback! So... I removed the Int. I created two constants. One with a double, and the second using the first, using operators. Then used string interpolation to return a full sentence with correct spelling.


Hacking with Swift is sponsored by Essential Developer.

SPONSORED Join a FREE crash course for mid/senior iOS devs who want to achieve an expert level of technical and practical skills – it’s the fast track to being a complete senior developer! Hurry up because it'll be available only until July 28th.

Click to save your free spot now

Sponsor Hacking with Swift and reach the world's largest Swift community!

Archived topic

This topic has been closed due to inactivity, so you can't reply. Please create a new topic if you need to.

All interactions here are governed by our code of conduct.

Unknown user

You are not logged in

Log in or create account

Link copied to your pasteboard.