#WSQ07

--Originally published at OlafGC / Class #TC1017

Here it is, the first time I used vectors. You have to get used to it because the logic of calling a function and then the parameter is not something we are pretty used to, so I need a lot of practice. Also, a friend of mine helped me realizing I have committed a mistake: calling a function “sum”. Please, if you are going to name functions, use another name. If you need help, just send me a Twitter.

Code

#include <iostream>
#include <vector>
#include <cmath>
using namespace std;

float suma (vector<float> list)
{
float suma=0, n=0;
for (int count=0; count<10; count++)
{
suma+=list[count];
} return suma;
}

float average(vector<float> list)
{
float average;
average=suma(list)/10;
return average;
}

float stdv(vector<float> list)
{
float sigma=0, stdv=0;
for (int count=0; count<10; count++)
{
sigma+=pow(list [count]-average(list), 2);
}
stdv=sqrt(sigma/10);
return stdv;
}

int main()
{
vector <float> list;
float n,av,dev,sum;
cout<<“Please insert 10 numbers:”<<endl;

for(int count=0; count<10; count++)
{
cin>>n;
list.push_back(n);
}
cout<<“The sum of the numbers is “<<suma(list)<<“.”<<endl;
cout<<“The average of the numbers is “<<average(list)<<“.”<<endl;
cout<<“The standart deviation of the numers is “<<stdv(list)<<“.”<<endl;
}


Ciento noventa y seis.

--Originally published at Loading…

This one was very hard! Es por eso que este post lo haré en español, para poder explicar CADA UNO DE LOS PASOS de la manera más clara y sencilla, y así ustedes puedan entenderme y tal vez aclarar sus dudas.

Lo primero que hice, fue descargar la carpeta que Ken tiene en Github, la verdad es que de eso no les puedo decir mucho porque estaba completamente perdida y Ken fue quien instaló todo eso en mi computadora. Después de ver que el código base de YoSoy196 funcionaba, me puse a investigar sobre lo que se supone que debe de hacer este código, vi los videos de Ken y revise los blogs de cursos anteriores, hasta que que encontré el código de Antonio, la verdad me fue de demasiada ayuda, gracias a él comprendí lo que debía de hacer y dejé de estar taaaaan perdida.

So…. lo primero es establecer las bibliotecas que vamos a usar, para que el programa corra necesitamos las bibliotecas string, iostream y BigIntegerLibrary.hh, que está incluida en la carpeta yosoy196 (la que acabamos de descargar). Después debemos de definir las funciones que necesitamos, en este caso solo necesitamos dos. La primer función es el bool is_palindrome, el cual recibe un string para poder analizar los datos, y tiene un if con la condición que si el string i  es leído de la misma manera comenzando en el inicio como en el final, regrese un valor verdadero, de no ser así, regrese falso. La segunda función que usé es BigInteger apply196, que también recibe un string y establece uno nuevo, el cual es el string i leído a la inversa, y por último use stringToBigInteger para que regrese los valores de string a un valor de BigInteger (que es lo que usamos para nuestra variable n), y

01C196.jpg
Diagrama
02C196.jpg
03C196.jpg
196
Continue reading "Ciento noventa y seis."

Final Project (in process)

--Originally published at Tec Life

Well, in this blog I am going to explain what are we going to do in our final project, in whats we are working, whats things we have do, whats things are in process, what we have learn it and more. ?

The Team:

  • Marijose Santoyo ♣
  • Irlanda de la Torre ♦
  •  Oscar Herrera ♠

So, what are we going to do??????……

The thing in what are we working is a glove that receives motion signals for our hands that can control almost everything depending the how we program it ????

FLM2HIEHWG095RA.LARGE.jpg

With this glove we can almost do everything we want ?, so with what are we working????F6RIPAPHQF9H5IO.MEDIUM.jpg

This is an arduino uno, Arduino is an open-source electronics platform based on easy-to-use hardware and software.Arduino boards are able to read inputs – light on a sensor, a finger on a button, or a Twitter message – and turn it into an output – activating a motor, turning on an LED, publishing something online. You can tell your board what to do by sending a set of instructions to the microcontroller on the board. To do so you use the Arduino programming language (based on Wiring), and the Arduino Software (IDE), based on Processing ??.

We already are working in how does an arduino works, and we found out a lot of things, so we are doing like mini projects to know more how to use correctly an arduino and to know how the glove is going to work.

We don’t have the parts that we are going to need to use the arduino, but we already have a lot of things to work in the mini projects ????, so basically we are waiting the controllers that we are going to need and while we are working in how know more the arduino ?.

So this is all for the moment, later we

?
?
?
Continue reading "Final Project (in process)"

THE List -.-‘! (WSQ07)

--Originally published at Programming Path

What a way to give me stress! This task gave me a lot of problems, because it was the first time for me to use arrays, and I looked it in the textbook of the course but didn’t help that much. Then I looked for arrays in the net. I found a tutorial of arrays that explains what are they for and how to use them.

Anyway, the task was this:

Create a program that asks the user for 10 numbers  (floating point). Store those numbers in a list. Show to the user the total, average and standard deviation of those numbers.

We could use arrays or vectors. I didn’t know neither of those, but is never too late to try learn something new. After I understood a little about how do the arrays work I started writing my code. Everything was fine until I needed the standard deviation. To be honest, I did not know what was the standard deviation until this task, I don’t even remember seeing it in elementary school, or middle school, so I had to look for the formula. Here is the formula:

formula
by Kaela Parkhouse

After finding the formula, it gave me a lot more trouble because I had to assign more variables. And that is how I ended up with this code. Not vary proud of this:

#include <iostream>
#include <cmath>
using namespace std;

float total, av, stde, s;
float StandardD (float,float,float,float,float,float,float,float,float,float);

int main () {
float a, b, c, d, e, f, g, h, i, j;
float foo [] = {a, b, c, d, e, f, g, h, i, j};
cout << “Enter 10 numbers. I will give you the total, average and stadard deviation of them.” << endl;
cout << endl << “Number 1: “;
cin >> a;
cout << endl

WSQ07
Continue reading "THE List -.-‘! (WSQ07)"

Well… :) not to easy

--Originally published at Tec Life

This was the problem:

Create a program that asks the user for 10 numbers  (floating point). Store those numbers in a list. Show to the user the total, average and standard deviation of those numbers.

This was a hard one, in this problem you need to convine everything you know about programming till now… so, not to easy.

The first thing that I do was doing an array of 10 digits and a cout to the user can type his 10 numbers, then I add a counter to now how many times I am going to put a number, and I make a operation that does that the numbers going to add each other, then I put that the average is equal to the sum divided the times I put a number, that was all in the first part.

The second part was to make a function that gives the standard deviation of the numbers I put (image 2), so I search on internet what to do to make that operation and I do the same as the average but a little different, it was a kind of pitágoras.

Captura de pantalla 2017-03-06 a la(s) 08.59.02.pngCaptura de pantalla 2017-03-06 a la(s) 08.59.15.pngCaptura de pantalla 2017-03-06 a la(s) 09.01.05.png


Quiz 9!!!!

--Originally published at Tec Life

 

This quiz was easy af!!! ….. well not at all ?

This was the quiz:

Write a function that receives four parameters: x1, y1, x2, y2 which are all floating point values.

The function is called distance and returns (float) the distance between x1,y1 and x2,y2 on the cartesian coordinate plane.

So, to solve this quiz you need to think hard, very hard, very very very hard!!!!!!, just kidding, you only have to use logic :p

Lets suppose that you have to points in the space x and y but these seams very familiar isn’t it? I think they are going to form a triangle and the space is the hypotenuse, lets see it like this el-plano-cartesiano-7-638.jpg

and then everything is solve, yo just only have to write your program like every time and everything is solve Ta Daaaa. ?

See you laterrrrrr.

Captura de pantalla 2017-03-11 a la(s) 09.23.56.png


Distance gave us a reason to love harder ??

--Originally published at Loading…

I know I have a title very “paleta”, buuuuuut Ken’s image really really made me laugh. Anyway the quiz of today was TOO EASY! This was the activity:

Write a function that receives four parameters: x1, y1, x2, y2 which are all floating point values.

The function is called distance and returns (float) the distance between x1,y1 and x2,y2 on the Cartesian coordinate plane.

So the first thing was to established the libraries that I’ll use, iostream & cmath. Then, I wrote my function, actually it was easy, I just used the Pythagoras’ Theorem

pythagorean_theorem11

One corner is one of the coordinates (X1, Y1), and the other (non the 90° corner) is the other coordinates (X2, Y2). So, in order to calculate a and b I used the logic and the Cartesian coordinate plane, now a is (X2 – X1), b is (Y2 – Y1) and c is the distance. To calculate the distance I used a sqrt and pow to raise to the square a and b.  This is my code, to be more clearly:

Distance

And this is how it works:

Distance01


Fibonacci Number!

--Originally published at Loading…

Hi! I know that I should have posted this since Friday, but I couldn’t post it before.

This quiz was a kind of… different, at the begging I didn’t understand very well it said:

Write a function that calculates returns the “nth” Fibonacci number where we define a function over the Fibonacci numbers mapping the naturals (starting with zero) to the Fibonacci series. So fibonacci(0) returns 0, fibonacci(1) returns 1, fibonacci(2) returns 1 and so on. Note that we are using the modern definition where the sequence starts with zero.

I know the Fibonacci series since the elementary school and I think it is absolutely AMAZING! But I didn’t know there was a formula to calculate any number in the series and that was the interesting part about this quiz, Ken gave us a very clearly explanation about it.

This is my code:

fibonacci01fibonacci02

While I was searching about the Fibonacci number and how my others classmates did this quiz, I found this page and I copied and pasted it one of the codes to print the series int he program, I know it’s wrong but it gave me a little laziness to do it by myself. It easier made the program with a function. At the begging I don’t understand how I supposed to count the numbers in the series but then Ken explained me that I have to star with the 0 like 0, 1, 2, 3… and this is how it works:

fibonacci03

P.S: It supposed that between the 0 and the 1 there should be a space.


FactorialCalculator???

--Originally published at Tec Life

Well, I do no what is a factorial…. ?

So in order to solve this problem I search on the most trusthly page on internet… Wikipedia, then I notice that a factorial is :

In mathematics, the factorial of a non-negative integer n, denoted by n!, is the product of all positive integers less than or equal to n. For example,

5!=5×4×3×2×1=120. 5!=5\times 4\times 3\times 2\times 1=120.\

So the problem was this:

Create a program that asks the user for a non-negative integer (let’s call that number n) and display for them the value of n! (n factorial).

After showing them the answer, ask them if they would like to try another number (with a simple y/n response) and either ask again (for y) or quit the program and wish them a nice day (if they answered n).

And then to solve this problem I put my normal main and later I do my function that says that is going to start in 1 because cero isn’t important, so while c is less than 1 is going to sum 1 till reach that number that the user input, and then is going to return me the new value that is going to be a or the result :).

captura-de-pantalla-2017-02-27-a-las-11-12-10

vLYLQ.gif

 

Image from: http://weknowmemes.com/2012/07/fuck-you-science/http://giphy.com/gifs/math-zach-galifianakis-the-hangover-5yLgoczEvFoE5LyoiZO


Functions??? Againnnnn???

--Originally published at Tec Life

Wellllll…. Again pffff.

The problem was this:

You will go back and do WSQ01 – Fun with Numbers again.

But this time, write a function for each calculation. Each function should define two parameters (in this example of type int) and return the correct value as an integer as well.

You main program needs to ask the user for the input and then call each function to calculate the answer for each of the parts.

So I use my older program and I start work in there, the only different thing that I do is that in this program I am going to use functions.

So I do thissssss, I give name to my function, then I put the values as int that are going to be on my functions, then I give value to my function and then return my function and the other functions was easy tooooo, the only thing that I do was change the operation of my function for what I suppose to need. And I do everything in one program why not?

Like this:captura-de-pantalla-2017-02-27-a-las-11-07-59

Image from: http://mathematicaled107.blogspot.mx