How to resolve the algorithm Temperature conversion step by step in the R programming language

Published on 12 May 2024 09:40 PM
#R

How to resolve the algorithm Temperature conversion step by step in the R programming language

Table of Contents

Problem Statement

There are quite a number of temperature scales. For this task we will concentrate on four of the perhaps best-known ones: Kelvin, Celsius, Fahrenheit, and Rankine. The Celsius and Kelvin scales have the same magnitude, but different null points. The Fahrenheit and Rankine scales also have the same magnitude, but different null points. The Celsius/Kelvin and Fahrenheit/Rankine scales have a ratio of 5 : 9.

Write code that accepts a value of kelvin, converts it to values of the three other scales, and prints the result.

Let's start with the solution:

Step by Step solution about How to resolve the algorithm Temperature conversion step by step in the R programming language

Source code in the r programming language

convert_Kelvin <- function(K){
    if (!is.numeric(K)) 
      stop("\n Input has to be numeric")
    
    return(list(
      Kelvin = K,
      Celsius = K - 273.15,
      Fahreneit = K * 1.8 - 459.67,
      Rankine = K * 1.8  
    ))
    
  }
  
  convert_Kelvin(21)


  

You may also check:How to resolve the algorithm Eban numbers step by step in the Wren programming language
You may also check:How to resolve the algorithm Convex hull step by step in the Maple programming language
You may also check:How to resolve the algorithm SHA-1 step by step in the LiveCode programming language
You may also check:How to resolve the algorithm Infinity step by step in the Modula-3 programming language
You may also check:How to resolve the algorithm Hello world/Standard error step by step in the Scala programming language