From 4c0c6ddaf049eb8f25d00c69d2b1c215b9cec959 Mon Sep 17 00:00:00 2001 From: sigonasr2 Date: Fri, 3 Nov 2023 11:52:19 -0500 Subject: [PATCH] Add 'loubi.cpp' --- loubi.cpp | 60 +++++++++++++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 60 insertions(+) create mode 100644 loubi.cpp diff --git a/loubi.cpp b/loubi.cpp new file mode 100644 index 0000000..0e885a4 --- /dev/null +++ b/loubi.cpp @@ -0,0 +1,60 @@ +int main() +{ + float Celsius, Fahrenheit, Kelvin; + int choice; + + printf("Hello, this program is a converter for the temperature \n"); + printf("You need a choice for Celsius, Fahrenheit, Kelvin \n"); + printf("1 = Celsius, 2 = Fahrenheit, 3 = Kelvin \n"); + scanf("%d", &choice); + + while(1) + { + switch (choice) + { + case 1: + printf("The Celsius is: \n"); + scanf("%f", &Celsius); + + Fahrenheit = (Celsius * (9.f/5.f)) + 32.f; + Kelvin = Celsius + 273.15f; + + printf("Fahrenheit = (Celsius * 9/5) + 32 \n"); + printf("%f degrees Celsius equals %f degrees Fahrenheit \n", Celsius, Fahrenheit); + printf("Kelvin = Celsius + 273.15\n"); + printf("%f degrees Celsius equals %f degrees Kelvin \n", Celsius, Kelvin); + break; + + case 2: + printf("The Fahrenheit is: \n"); + scanf("%f", &Fahrenheit); + + Fahrenheit = (Celsius * 1.8f); + Kelvin = Celsius - 273.15f; + + printf("Fahrenheit = (Celsius * 1.8) \n"); + printf("%f degrees Fahrenheit equals %f degrees Celsius \n", Fahrenheit, Celsius); + printf("Fahrenheit = (Celsius * 1.8) \n"); + printf("Kelvin = Fahrenheit equals %f degrees Kelvin \n", Fahrenheit, Kelvin); + break; + + case 3: + printf("The Kelvin is: \n"); + scanf("%f", &Kelvin); + + Kelvin = Fahrenheit (1.8f * Kelvin) - 459.67f; + Kelvin = Celsius - 273.15f; + + printf("Kelvin = (Fahrenheit * 1.8) \n"); + printf("%f degrees Fahrenheit equals %f degrees Kelvin \n", Kelvin, Celsius); + printf("Kelvin =(Celsius * 1.8)\n"); + printf("Kelvin = Fahrenheit equals %f degrees Kelvin \n", Fahrenheit, Kelvin); + break; + + default: + printf("The value is not a number !"); + break; + } + } + return(0); +} \ No newline at end of file