How to resolve the algorithm Temperature conversion step by step in the Ada programming language
Published on 12 May 2024 09:40 PM
How to resolve the algorithm Temperature conversion step by step in the Ada 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 Ada programming language
Source code in the ada programming language
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;
You may also check:How to resolve the algorithm Null object step by step in the Common Lisp programming language
You may also check:How to resolve the algorithm Zig-zag matrix step by step in the ooRexx programming language
You may also check:How to resolve the algorithm Greatest element of a list step by step in the Phixmonti programming language
You may also check:How to resolve the algorithm Inheritance/Multiple step by step in the Ada programming language
You may also check:How to resolve the algorithm A+B step by step in the ALGOL 60 programming language