Tag Archives: #Temperature

Temperature (Use of conditionals)

This program is intented to be an intruction to conditionals statements if and else. 

The program consist in asking the Temperature in Farenheit to the user, transform it into Celcius, print it in the screen and then letting the user know if water would be boiling or not. 

The source code is this:

temp=float(input(“What is the temperature in Fahrenheit? “))

 

temp=5*(temp-32)/9

print(temp,”ºC”)

 

if(temp<100):

    print(“Water is not boiling”)

else:

    print(“Water is boiling”)

Where we can see how we ask for the temperature to the user and then store it in the variable temp, wich in this case I have declared it as a float, just to get decimals nothing more. 

Then we apply the formula to convert Farenheit into Celcius and store it in the same variable we have created before. If we wanted to recieve an integer answer we could use a floor division // instead of the /.

Then comes the conditionals, the if statement evaluates the expression inside the parenthesis and if the expression returns a true value it execute the code below. The else statement is used to have an alternative when the if statemen expresion returns a false, if it does it executes the block of code below that has the appropiate identation.

Here you can have more information and examples to the use of conditional statements.

This is for my of my course.

#WSQ05 #Temperature

1 min read

Hey programmers!

Hereby I show you a program that I wrote , is my first code using “is” and “else”,

I hope it will help you and if you have any problem let me a comment.

 #Temperature

 

Here is my code: 

 

#WSQ05 Temperature

1 min read

Before you start reading my post, please click this link to listen to the correct music for this: Link to video

Code down below: 

//Mauricio Cooper A01630042

<iostream>

using namespace std;

int C,F;

int main () {

 

cout << endl;

cout << “Enter a Fahrenheit Degrees Temperature” << endl;

cout << endl;

cin >> F ;

cout << endl;

C=5*(F-32)/9;

cout << “Your temperature in Celsius degrees is: ” << C << endl;

cout << endl;

 

if (C >= 100){

cout << “Water would boil at this temperature. This crap is hot.”;

}

 

if (C <=0) {

cout << “Water would freeze at this temperature. Cold as your GF.”;

}

if (C > 0 && C < 100) {

cout << “Water neither freeze nor boil. Fresh as fuck.”;

}

 

cout << endl;

return 0;

}

 

WSQ05 – Temperature

1 min read

#WSQ05 #TC1017 #Temperature

For this activity we have to ask a temperature in Fahrenheit and convert it to Celsius.

First of all, I found useful information in our course book, in the part 4.2 Conditional execution; also we have to declare float variables because we are not using integer values, in this page I found some information about that:

http://www.tutorialspoint.com/cplusplus/cpp_variable_types.htm

The new thing that I learned in this activity is how to use the conditional “if/else”, the structure is really simple. In the condition “if” you only have to write a TRUE condition for an action, and you have to put “else” to indicate a FALSE condition for the same action.

In the following link you will find my c++ code:

https://drive.google.com/drive/#folders/0B-NM4ghaDXBvbk5Wcmc2R3d3V3c

And I will share some pictures, one of them is my c++ code and the other one is the program working.