#WSQ05 Temperature. Fahrenheit to Celsius.

Hello again to all my friends.

Well, we’re coming back with programming posts. Now i’m gonna post my new program that consists in convert the temperature from Fahrenheit to Celsius. It wasn’t hard because before we learnt how to ask for variables, how to read them and how to use them. So now, we just have to put the correct formula and run it.

So, here the screenshot of my program.

temp

And the program running.

gtem

If you have any question add a comment and I will help you!.

In the next link you can see my complete code:

https://github.com/eduardomrlsg/TC101/blob/master/Temperature

Also I recommend to visit the site cplusplus.com to know new commands and tools that make C++ easier and to understand better.

Temperature

Hi!

Welcome again. Now I made a code using temperature.

Instructions:

Write a program that will prompt the user for a temperature in Fahrenheit and then convert it to Celsius. You may recall that the formula is C = 5 ∗ (F − 32)/9.

Modify the program to state whether or not water would boil at thetemperature given. Your output might look like the following.

And this is the Code:

temp

The main point is to convert Fahrenheit degrees to Celsius degrees. We all know that simple formula to convert the degrees: C = 5 ∗ (F − 32)/9.

Steps:

  1. Ask to the user to write the Celsius degrees (remember to save the variable with CIN).
  2. Use the formula in a way the computer can understand and the computer is going to convert the degrees.
  3. Show the Celsius Degrees.

Now I’m going to introduce IF and ELSE.

We use IF and ELSE to compare two or more sets of data and tests the results. If the results are true, the THEN instructions are taken; if not, the ELSE instructions are taken. (http://www.pcmag.com/encyclopedia/term/44748/if-then-else).

In this case IF temperature is more than 100° Celsius it will show up a message (“El agua hierve a esta temperatura”). BUUUUUT IF NOT it will show you another message (“El agua no hierve a esta temperatura”).

The basic structure is:

If (condition)

{ make this }

else

{ make this }

It isn’t really difficult. I have some knowledge of this because I took a course of an introduction to code.

Thanks for coming! See you later.

Code Link:

https://www.dropbox.com/s/5nynn2ucy8pluf3/Temperature.cpp?dl=0

#WSQ05, PROGRAMA PARA CONVERTIR °F -> °C (detectar si el agua hierve a la temperatura dada)

temp
Este es un programa para poder convertir grados farenheit a celsius y detectar si el agua hierve a la temperatura dada, tomamos en consideración la fórmula de C=5*(F-32)/9. *los t sirven para dar espacios. *los <<endl; sirven para saltar de linea. En este programa usamos if’s debido a que dependiendo de la temperatura que dé el usuario, y cuanto sea su equivalencia en °Celsius, te deberá imprimir si la temperatura es suficiente para que el agua ebulla, o si no lo es entonces, si la temperatura equivalente en °C ósea si C==100 (los 100 grados a los que sabemos que ebulle el agua) entonces imprimirá que a esa temperatura ebulle, si no (else), si (if) es menor la temperatura, deberá imprimir que a esa temperatura no ebulle, y si no (else), si (if) es mayor, pues que a esa temperatura ya esta hirviendo el agua.
menostemperatura
Como podemos observar si aquí ponemos un valor de 23° Farenheit, que es el equivalente a -5° Celsius, se imprime que el agua aún no esta hirviendo a esa temperatura, que requiere más temperatura.
latemperatura
Como podemos ver, al poner la temperatura de 212° Farenheit, que es el equivalente a 100° Celsius, nos sale que a esa temperatura es a la que hierve el agua.
muchomastemperatura
En este caso, si ponemos una temperatura superior a los 212 en grados Farenheit que equivalen a los 100° Celsius en los que ya esta hirviendo el agua, vemos que los 300° Farenheit que pusimos equivalen a 148° Celsius, lo cual no sindica que el agua a esa temperatura ya esta hirviendo y de hecho se pasa.

WSQ05 – Temperature

código

#include <iostream>
#include <stdio.h>
using namespace std;
int main()
{
float Fa,Ce;
cout <<“Temperaturer”;
cout <<“nWhat is the temperature in Fahrenheit?”;
cin >>Fa;
Ce = 5 * ( Fa – 32 ) / 9;
cout <<“A temperature of ” << Fa <<” degrees Fahrenheit is ” << Ce <<” in Celsius.”;

if (Fa <= 32)
{
cout <<“nWater does not boil at this temperature (under typical conditions).”;
}
else
{
cout <<“nWater boil at this temperature (under typical conditions).”;
}
getchar();
return 0;
}

Temperature (WSQ05)

This homework is about converting Fahrenheit degrees to Celsius. The deal is that we need to ask the user for the temperature in Fahrenheit, and the code does the rest to convert that quantity to Celsius.

As I need the user to give me the number, I enter an input in my program, and I assign a variable to it. I will assing the variable “f”

temperature 01 - copia

To do the math process, we need to create another variable, so then a result can be printed.

temperature 01

My new variable is “c”, followed by the operation that will convert the Fahrenheit degrees to Celsius. I should be careful in this part because at the beginning I wasn’t writing the right syntax, so I had to try many times to get the right result, my advice is: be careful with the parentheses.

The formula is  C = 5 ∗ (F − 32)/9 we just need to transform that in a code. I’m telling the program that I just need the integer result with the “int” label, before the whole sentence.
Then I need my “f” variable. Let’s convert all our numbers to integers, I won’t use any float today, so I’m converting my “f” variable to an integer “int”.

temperature 01 - copia (2)

Let’s print the result. To include the variables in the sentence, we must close the (“), type a (,) and then the variable. Like in the picture above.

temperature 01 - copia (2)

The rest is easy. It’s necessary to indicate if the temperature that the user give us would make the water boil, freexe or none of them. We get that with the “if” label.

In the first “if” sentence, I needed to indicate the “range” in which the water is neither boiling nor freezing. We print the sentence that will indicate the result to our user. NOTE: you should type

temperature 02

Continue reading “Temperature (WSQ05)”

Temperature

This program works by asking some temperature in Fahrenheit and then convert it to Celsius. This program was not so easy but not very hard, so here i have my program in Atom.

temperature

I have a very dumb problem because when I thought that it was done, I did it as the other two, I compile it and try to run it,  but when I tried that there was not a response with the temperature in Celsius, jaja I forgot to tell the program to give me the response. Then when I was getting crazy I re-checked the hole program and I find out that error.

And here is how the program works.

temperature1