WSQ 03 – Pick a Number (Week 04)

--Originally published at Ernesto's Computing Works

Este fue mi cuarto trabajo, en lo personal fue el mas divertido porque después de que logre programarlo, me puse a jugar. Este programa se trataba de que la computadora escogía un numero de 1 al 100 y el usuario debía adivinar ese numero, y tenia los intentos que quisiera. Si tu ponías un numero que no era, el programa te decía si el numero era mayor o menor al que el usuario decía y así tratabas de adivinar hasta acercarse mas al numero, al final obtenías el numero de intentos que usaste para adivinar el numero. Así como fue el mas divertido, a mi parecer fue el mas difícil porque, bueno importe otras librerías que nunca había importado y no sabia bien como usarlas ademas que los comando tampoco los conocía

Screenshot 2017-08-29 10.51.40

Para lograr este programa tuve que combinar poniendo varios conditionals dentro de un loop, ademas que gran parte de este programa pedí ayuda a un amigo y al teacher porque para entonces estaba muy difícil el nivel del programa. La mitad la hice yo solo pero después necesite ayuda.


WSQ 03

--Originally published at MarizProfile

Captura de pantalla 2017-09-08 a la(s) 17.48.15

This was the first time I had to use a do while loop, in order to repeat several times some steps in my code. I had to declare a variable x=0, and then I had to create a counter “x=x+1”. Then, at the end of the loop I had to establish a conditional “while”, assigning a value to “x” lower than 4, so that the loop repeated itself 4 times (as long as the user didn’t guess the right Random Number the system would generate each 0 seconds). <– To do this, I looked up for the right tool, that let me command the system to generate a random number each determined amount of time, in this case, every 0 seconds (constantly generating it), using “srand (time(0));”


Pick a number

--Originally published at Programming in C++

The Program:

 

Imagen1

For this program we use 2 more libraries besides iostream. First we use srand. This is going to give us a random number.

The problem is that it will give us the same random number every time we run it.

To change that we are going to add the library time, this is going to set the random number to the current time, so it won’t give the same number unless you run it at the same second.

We are also going to need a several loops. First we want the program to run every time we insert an incorrect number, for this we use a “while”. Then we use “if” to condition when the given number is too high or too low, and for when the number is actually correct.

I consult K Hong blog. Which explains in a better way the random part. I also found this image about it:

Dilbert_random


Temperature

--Originally published at Programming in C++

 

Tqw02he program uses the formula c=5*(F-32)/ that is just to convert farenheit to celsius

The user insert the temperature in F.

Then the program has to say if the water will boil. For this we use a if. So, if the temperature is bigger than 100 c (celsius>100) the water will boil, and if the temperature is smaller than 100 c (celsius<100) the water will not boil.

The bash should look something like this: qw021

 


WSQ03 – Pick a number.

--Originally published at August-December 2017 – Blogging through my thoughts

Good morning!

The third task was to create a program that picks a random integer in the range of 1 to 100. After that , the game starts when the user has to guess which number does the program picked, with hints of ’too high’ or ’too low’.

The program continues to run until the user guesses the integer.

I added some extra steps, because I wanted to show more information to the users , like:

¿How many guesses they had to make to get the right answer?

______________________________________________________________________________________________

The resources that helped me were:
-How to think like a computer scientist.

-cplusplus.com

-cppreference.com

-Programming hub, mobile app.

WSQ03ATOM1

WSQ03ATOM2
Atom code.
WSQ03UBUNTU
Ubuntu commands.

WSQ03MASTERY

Until next time!


Elige un número

--Originally published at RON

Esta práctica me pareció muy divertida pues una vez realizada, me divertí jugando con algo que yo mismo había creado. Tuve algunas dudas durante la realización de la practica pero gracias a las consultas realizadas en las paginas y el libre que agrego al final, todo funciono perfectamente. Dejo mi link para que chequen mi archivo .cpp, en la parte inferior.

Páginas de internet:
https://www.programarya.com/Cursos/C++/Ciclos/Ciclo-While
Programación en C++ : 6 Ciclos, Contadores y Acumuladores

Libro:

Enciclopedia del lenguaje C++, 2a edición, del autor Fco. Javier Ceballos Sierra.

Haga click para ver el pase de diapositivas.

Enlace código .cpp:

https://drive.google.com/a/itesm.mx/file/d/0BwFGq6oJuVvVbTJJU3FJVzZLN3M/view?usp=sharing