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

Published on 12 May 2024 09:40 PM

How to resolve the algorithm Temperature conversion step by step in the Visual FoxPro 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 Visual FoxPro programming language

Source code in the visual programming language

#DEFINE ABSZC 273.16
#DEFINE ABSZF 459.67
LOCAL k As Double, c As Double, f As Double, r As Double, n As Integer, ;
cf As String
n = SET("Decimals")
cf = SET("Fixed")
SET DECIMALS TO 2
SET FIXED ON
CLEAR
DO WHILE .T.
    k = VAL(INPUTBOX("Degrees Kelvin:", "Temperature"))
    IF k <= 0
    EXIT
    ENDIF   
    ? "K:", k
    c = k - ABSZC
    ? "C:", c
    f = 1.8*c + 32
    ? "F:", f
    r = f + ABSZF
    ? "R:", r
    ?
ENDDO   
SET FIXED &cf
SET DECIMALS TO n


  

You may also check:How to resolve the algorithm Sum and product puzzle step by step in the Perl programming language
You may also check:How to resolve the algorithm Find limit of recursion step by step in the CoffeeScript programming language
You may also check:How to resolve the algorithm Pangram checker step by step in the Sidef programming language
You may also check:How to resolve the algorithm Self-describing numbers step by step in the zkl programming language
You may also check:How to resolve the algorithm Rosetta Code/Count examples step by step in the Ring programming language