Data update
This commit is contained in:
parent
4bb20c9b71
commit
cbaf4c4b64
12390 changed files with 318560 additions and 27248 deletions
14
Task/Temperature-conversion/Ada/temperature-conversion.adb
Normal file
14
Task/Temperature-conversion/Ada/temperature-conversion.adb
Normal file
|
|
@ -0,0 +1,14 @@
|
|||
with Ada.Float_Text_IO, Ada.Text_IO; use Ada.Float_Text_IO, Ada.Text_IO;
|
||||
|
||||
procedure Temperatur_Conversion is
|
||||
K: Float;
|
||||
function C return Float is (K - 273.15);
|
||||
function F return Float is (K * 1.8 - 459.67);
|
||||
function R return Float is (K * 1.8);
|
||||
begin
|
||||
Get(K); New_Line; -- Format
|
||||
Put("K: "); Put(K, Fore => 4, Aft => 2, Exp => 0); New_Line;-- K: dddd.dd
|
||||
Put("C: "); Put(C, Fore => 4, Aft => 2, Exp => 0); New_Line;-- C: dddd.dd
|
||||
Put("F: "); Put(F, Fore => 4, Aft => 2, Exp => 0); New_Line;-- F: dddd.dd
|
||||
Put("R: "); Put(R, Fore => 4, Aft => 2, Exp => 0); New_Line;-- R: dddd.dd
|
||||
end;
|
||||
|
|
@ -0,0 +1,20 @@
|
|||
; ### USAGE - TESTING PURPOSES ONLY
|
||||
|
||||
Local Const $_KELVIN = 21
|
||||
ConsoleWrite("Kelvin: " & $_KELVIN & @CRLF)
|
||||
ConsoleWrite("Kelvin: " & Kelvin(21, "C") & @CRLF)
|
||||
ConsoleWrite("Kelvin: " & Kelvin(21, "F") & @CRLF)
|
||||
ConsoleWrite("Kelvin: " & Kelvin(21, "R") & @CRLF)
|
||||
|
||||
; ### KELVIN TEMPERATURE CONVERSIONS
|
||||
|
||||
Func Kelvin($degrees, $conversion)
|
||||
Select
|
||||
Case $conversion = "C"
|
||||
Return Round($degrees - 273.15, 2)
|
||||
Case $conversion = "F"
|
||||
Return Round(($degrees * 1.8) - 459.67, 2)
|
||||
Case $conversion = "R"
|
||||
Return Round($degrees * 1.8, 2)
|
||||
EndSelect
|
||||
EndFunc ;==> Kelvin
|
||||
|
|
@ -0,0 +1,28 @@
|
|||
@echo off
|
||||
setlocal enableextensions enabledelayedexpansion
|
||||
set /p n=
|
||||
set "tempstr=%n:.= %"
|
||||
call :assignnum %tempstr%
|
||||
set /a res=n & call :disp K
|
||||
set /a res-=27315 & call :disp C
|
||||
set /a res=(res*18+32000)/10 & call :disp F
|
||||
set /a res=res+45967 & call :disp R
|
||||
goto:eof
|
||||
|
||||
:assignnum
|
||||
set tempstr=%2
|
||||
if not defined tempstr goto:setzero
|
||||
2>nul set /a tempstr=%tempstr:~0,2%||goto:setzero
|
||||
set /a "n=tempstr%%10"
|
||||
if "%n%"=="%tempstr%" set tempstr=0%tempstr%
|
||||
:_assign
|
||||
set /a n=%1%tempstr%
|
||||
goto:eof
|
||||
|
||||
:setzero
|
||||
set tempstr=00
|
||||
goto :_assign
|
||||
|
||||
:disp
|
||||
echo %1 %res:~0,-2%.%res:~-2%
|
||||
goto:eof
|
||||
36
Task/Temperature-conversion/COBOL/temperature-conversion.cob
Normal file
36
Task/Temperature-conversion/COBOL/temperature-conversion.cob
Normal file
|
|
@ -0,0 +1,36 @@
|
|||
IDENTIFICATION DIVISION.
|
||||
PROGRAM-ID. temp-conversion.
|
||||
|
||||
DATA DIVISION.
|
||||
WORKING-STORAGE SECTION.
|
||||
78 Kelvin-Rankine-Ratio VALUE 0.5556. *> 5 / 9 to 4 d.p.
|
||||
78 Kelvin-Celsius-Diff VALUE 273.15.
|
||||
78 Rankine-Fahrenheit-Diff VALUE 459.67.
|
||||
|
||||
01 temp-kelvin PIC S9(8)V99.
|
||||
01 temp-rankine PIC S9(8)V99.
|
||||
|
||||
01 kelvin PIC -(7)9.99.
|
||||
01 celsius PIC -(7)9.99.
|
||||
01 rankine PIC -(7)9.99.
|
||||
01 fahrenheit PIC -(7)9.99.
|
||||
|
||||
PROCEDURE DIVISION.
|
||||
DISPLAY "Enter a temperature in Kelvin to convert: " NO ADVANCING
|
||||
ACCEPT temp-kelvin
|
||||
|
||||
MOVE temp-kelvin TO kelvin
|
||||
DISPLAY "K " kelvin
|
||||
|
||||
SUBTRACT Kelvin-Celsius-Diff FROM temp-kelvin GIVING celsius
|
||||
DISPLAY "C " celsius
|
||||
|
||||
DIVIDE temp-kelvin BY Kelvin-Rankine-Ratio
|
||||
GIVING temp-rankine, rankine
|
||||
SUBTRACT Rankine-Fahrenheit-Diff FROM temp-rankine GIVING fahrenheit
|
||||
|
||||
DISPLAY "F " fahrenheit
|
||||
DISPLAY "R " rankine
|
||||
|
||||
GOBACK
|
||||
.
|
||||
|
|
@ -0,0 +1,5 @@
|
|||
print "K: "; STDOUT.flush
|
||||
k = gets.not_nil!.to_f
|
||||
|
||||
printf "= %7.2f °C\n= %7.2f °R\n= %7.2f °F\n",
|
||||
k - 273.15, k * 1.8, k * 1.8 - 459.67
|
||||
|
|
@ -0,0 +1,7 @@
|
|||
include std/console.e
|
||||
|
||||
atom K
|
||||
while 1 do
|
||||
K = prompt_number("Enter temperature in Kelvin >=0: ",{0,4294967296})
|
||||
printf(1,"K = %5.2f\nC = %5.2f\nF = %5.2f\nR = %5.2f\n\n",{K,K-273.15,K*1.8-459.67,K*1.8})
|
||||
end while
|
||||
|
|
@ -0,0 +1,23 @@
|
|||
import gleam/float
|
||||
import gleam/io
|
||||
import gleam/string
|
||||
|
||||
pub fn main() {
|
||||
convert(kelvin: 21.0)
|
||||
}
|
||||
|
||||
pub fn convert(kelvin kelvin: Float) -> Nil {
|
||||
let rankine = kelvin *. 9.0 /. 5.0
|
||||
show_temp(kelvin, "K")
|
||||
show_temp(kelvin -. 273.15, "C")
|
||||
show_temp(rankine -. 459.67, "F")
|
||||
show_temp(rankine, "R")
|
||||
}
|
||||
|
||||
fn show_temp(temperature: Float, unit: String) -> Nil {
|
||||
temperature
|
||||
|> float.to_precision(2)
|
||||
|> float.to_string
|
||||
|> string.append(" °" <> unit)
|
||||
|> io.println
|
||||
}
|
||||
|
|
@ -1,4 +1,4 @@
|
|||
cfr(k) = print("Kelvin: $k, ",
|
||||
"Celsius: $(round(k-273.15,2)), ",
|
||||
"Fahrenheit: $(round(k*1.8-459.67,2)), ",
|
||||
"Rankine: $(round(k*1.8,2))")
|
||||
"Celsius: $(round(k-273.15, digits = 2)), ",
|
||||
"Fahrenheit: $(round(k*1.8-459.67, digits = 2)), ",
|
||||
"Rankine: $(round(k*1.8, digits = 2))")
|
||||
|
|
|
|||
|
|
@ -0,0 +1,15 @@
|
|||
local fmt = require "fmt"
|
||||
|
||||
local function temp_conv(k)
|
||||
local c = k - 273.15
|
||||
local f = c * 1.8 + 32
|
||||
local r = f + 459.67
|
||||
fmt.print("%7.2f˚ Kelvin" , k)
|
||||
fmt.print("%7.2f˚ Celsius", c)
|
||||
fmt.print("%7.2f˚ Fahrenheit", f)
|
||||
fmt.print("%7.2f˚ Rankine", r)
|
||||
print()
|
||||
end
|
||||
|
||||
local ks = {0, 21, 100}
|
||||
for ks as k do temp_conv(k) end
|
||||
|
|
@ -0,0 +1,21 @@
|
|||
function temp($k){
|
||||
try{
|
||||
$c = $k - 273.15
|
||||
$r = $k / 5 * 9
|
||||
$f = $r - 459.67
|
||||
} catch {
|
||||
Write-host "Input error."
|
||||
return
|
||||
}
|
||||
|
||||
Write-host ""
|
||||
Write-host " TEMP (Kelvin) : " $k
|
||||
Write-host " TEMP (Celsius) : " $c
|
||||
Write-host " TEMP (Fahrenheit): " $f
|
||||
Write-host " TEMP (Rankine) : " $r
|
||||
Write-host ""
|
||||
|
||||
}
|
||||
|
||||
$input=Read-host "Enter a temperature in Kelvin"
|
||||
temp $input
|
||||
|
|
@ -0,0 +1,27 @@
|
|||
function Convert-Kelvin
|
||||
{
|
||||
[CmdletBinding()]
|
||||
[OutputType([PSCustomObject])]
|
||||
Param
|
||||
(
|
||||
[Parameter(Mandatory=$true,
|
||||
ValueFromPipeline=$true,
|
||||
ValueFromPipelineByPropertyName=$true,
|
||||
Position=0)]
|
||||
[double]
|
||||
$InputObject
|
||||
)
|
||||
|
||||
Process
|
||||
{
|
||||
foreach ($kelvin in $InputObject)
|
||||
{
|
||||
[PSCustomObject]@{
|
||||
Kelvin = $kelvin
|
||||
Celsius = $kelvin - 273.15
|
||||
Fahrenheit = $kelvin * 1.8 - 459.67
|
||||
Rankine = $kelvin * 1.8
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
@ -0,0 +1 @@
|
|||
21, 100 | Convert-Kelvin
|
||||
|
|
@ -0,0 +1,19 @@
|
|||
WScript.StdOut.Write "Enter the temperature in Kelvin:"
|
||||
tmp = WScript.StdIn.ReadLine
|
||||
|
||||
WScript.StdOut.WriteLine "Kelvin: " & tmp
|
||||
WScript.StdOut.WriteLine "Fahrenheit: " & fahrenheit(CInt(tmp))
|
||||
WScript.StdOut.WriteLine "Celsius: " & celsius(CInt(tmp))
|
||||
WScript.StdOut.WriteLine "Rankine: " & rankine(CInt(tmp))
|
||||
|
||||
Function fahrenheit(k)
|
||||
fahrenheit = (k*1.8)-459.67
|
||||
End Function
|
||||
|
||||
Function celsius(k)
|
||||
celsius = k-273.15
|
||||
End Function
|
||||
|
||||
Function rankine(k)
|
||||
rankine = (k-273.15)*1.8+491.67
|
||||
End Function
|
||||
Loading…
Add table
Add a link
Reference in a new issue