https://github.com/carbajal13itesm/Fundamentos-/blob/master/WSQ05
Tag: #WSQ05
Temperature
Temperature #WSQ05
#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.
And the program running.
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:
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:
- Ask to the user to write the Celsius degrees (remember to save the variable with CIN).
- Use the formula in a way the computer can understand and the computer is going to convert the degrees.
- 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)
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
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”
To do the math process, we need to create another variable, so then a result can be printed.
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”.
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.
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
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.
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.