ADVERTISEMENT
ADVERTISEMENT

Kotlin program to convert temperature from Fahrenheit to Celsius

Kotlin: Conversion from Fahrenheit to Celsius: Here, we are implementing a Kotlin program to convert temperature from Fahrenheit to Celsius.
Submitted by IncludeHelp, on May 12, 2020

Given temperature in Fahrenheit, we have to convert it into Celsius

Example:

    Input:
    Fahrenheit = 67

    Output:
    Celsius = 19.444444444444443

Program to convert temperature from Fahrenheit to Celsius in Kotlin

package com.includehelp

import java.util.*

//Main Function , Entry point of Program
fun main(args: Array<String>) {

    //Input Stream
    val scanner = Scanner(System.`in`)

    //Input temperature in Fahrenheit
    print("Enter temperature into Fahrenheit : ")
    val fahrenheit = scanner.nextDouble()

    //Convert  Fahrenheit to Celsius
    val celsius =( (fahrenheit  -  32  ) *  5)/9

    //Print temperature in Celsius
    println("Temperature in Fahrenheit ($fahrenheit) = Celsius ($celsius)")
}

Output

Output will be:
Run 1:
Enter temperature into Fahrenheit : 67
Temperature in Fahrenheit (67.0) = Celsius (19.444444444444443)
---
Run 2:
Enter temperature into Fahrenheit : 78
Temperature in Fahrenheit (78.0) = Celsius (25.555555555555557)
ADVERTISEMENT



ADVERTISEMENT



Comments and Discussions


ADVERTISEMENT

ADVERTISEMENT
ADVERTISEMENT
ADVERTISEMENT

Languages: » C » C++ » C++ STL » Java » Data Structure » C#.Net » Android » Kotlin » SQL
Web Technologies: » PHP » Python » JavaScript » CSS » Ajax » Node.js » Web programming/HTML
Solved programs: » C » C++ » DS » Java » C#
Aptitude que. & ans.: » C » C++ » Java » DBMS
Interview que. & ans.: » C » Embedded C » Java » SEO » HR
CS Subjects: » CS Basics » O.S. » Networks » DBMS » Embedded Systems » Cloud Computing
» Machine learning » CS Organizations » Linux » DOS
More: » Articles » Puzzles » News/Updates

© https://www.includehelp.com some rights reserved.