import "math"
call(add(5, 10)) # Importing the function from math.wthr
temp = 28.37 # Current temperature in Celsius
humidity = 75 # Current humidity percentage
fahrenheit = 82 # Current temperature in Fahrenheit
celsius = 28 # Current temperature in Celsius
kelvin = 301 # Current temperature in Kelvin
fn heat_index(temp, humidity) {
# Calculate the heat index
heat_index = 0 - 8.78469475556 + 1.61139411 * temp + 2.33854883889 * humidity - 0.14611605 * temp * humidity - 0.012308094 * temp * temp - 0.0164248277778 * humidity * humidity + 0.002211732 * temp * temp * humidity + 0.00072546 * temp * humidity * humidity - 0.000003582 * temp * temp * humidity * humidity
print("Heat Index: ")
print(heat_index)
}
# Function calling uses the `call` keyword
call(heat_index(temp, humidity))
# Calculate and print the dew point
dew_point = dewpoint(temp, humidity)
print("Dew Point: ")
print(dew_point)
# Convert Fahrenheit to Celsius and print the result
celsius_converted = ftoc(fahrenheit)
print("Fahrenheit to Celsius: ")
print(celsius_converted)
# Convert Celsius to Fahrenheit and print the result
fahrenheit_converted = ctof(celsius)
print("Celsius to Fahrenheit: ")
print(fahrenheit_converted)
# Convert Celsius to Kelvin and print the result
kelvin_converted = ctok(celsius)
print("Celsius to Kelvin: ")
print(kelvin_converted)
# Convert Fahrenheit to Kelvin and print the result
kelvin_converted = ftok(fahrenheit)
print("Fahrenheit to Kelvin: ")
print(kelvin_converted)
# Convert Kelvin to Fahrenheit and print the result
fahrenheit_converted = ktof(kelvin)
print("Kelvin to Fahrenheit: ")
print(fahrenheit_converted)
# Convert Kelvin to Celsius and print the result
celsius_converted = ktoc(kelvin)
print("Kelvin to Celsius: ")
print(celsius_converted)
# Conditional statement example for temperature
if (temp > 35) {
print("Heat advisory: It's extremely hot!")
} else {
if (temp > 30) {
print("It's a hot day!")
} else {
if (temp > 20) {
print("It's a warm day!")
} else {
if (temp > 10) {
print("It's a cool day!")
} else {
print("It's a cold day!")
}
}
}
}
# Conditional statement example for humidity
if (humidity < 30) {
print("It's a dry day!")
} else {
if (humidity < 60) {
print("It's a comfortable day!")
} else {
print("It's a humid day!")
}
}
# Example usage of Pi constant
radius = 5
# Built-in constants are surrounded by underscores
area = _pi_ * radius * radius
print("Area of the circle: ")
print(area)
# Example usage of the Kelvin constant
print("Absolute zero in Kelvin: ")
print(_kelvin_)
# Example usage of the gas constant for dry air
print("Gas constant for dry air: ")
print(_rd_)
# Example usage of the specific heat capacity of air
print("Specific heat capacity of air: ")
print(_cp_)
# Example usage of the standard atmospheric pressure
print("Standard atmospheric pressure: ")
print(_p0_)
# Example usage of the latent heat of vaporization for water
print("Latent heat of vaporization for water: ")
print(_lv_)
# Example usage of the specific heat capacity of water
print("Specific heat capacity of water: ")
print(_cw_)
# Example usage of the density of air
print("Density of air: ")
print(_rho_air_)
# Example usage of the density of water
print("Density of water: ")
print(_rho_water_)
# Example usage of the acceleration due to gravity
print("Acceleration due to gravity: ")
print(_g_)