Final Exam Practice

Hey guys!  I solved all the problems Ken uploaded as practice problems TC101_FinalExamQuestions (1) . The only one I did not do was number 9!! IF YOU HAVE THE SOLUTION FO THAT ONE PLEASE SHARE IT TO ME. Have fun.

HELLO EUCLID:

euclides_2

HERE IS THE CODE FOR EACH PROBLEM ON GITHUB:

Problem 1

Problem 2

Problem 3

Problem 4

Problem 6

Problem 7

PROBLEM 9: STILL MISSING! SHARE YOUR KNOWLEDGE WITH ME.

Problem 8 : TAKE A LOOK A THIS VIDEO TO UNDERSTAND: https://www.youtube.com/watch?v=sZmz7znP6x0

Problem 10 : THANKS TO THIS BLOG FOR HELPING ME OUT: http://fahad-cprogramming.blogspot.mx/2013/11/find-greatest-common-divisor-gcd-of-two.html

11 de Mayo, 2016

WSQ14-SciLab

SciLab is an incredibly useful software used to perform complex mathematical calculations, plots, etc. It works using  matrices. As explained in their introductory document:

“Scilab is not a computer algebra system. It calculates only with numbers. All calculations are done with matrices, although this may go unnoticed. Even if the concept of matrices is unknown, vectors and sequences of numbers can explain it, as they are, in fact, matrices of dimension 1 × n or n × 1 and a number is itself a matrix of dimension 1 × 1”

scilab.png

Take a look at a quick introductory video, made by myself (IN SPANISH):

PROJECT: DATE FINDER 1.0

Keep-Calm_Final-Project

The day to upload the final project arrived. And here it is, here I am! Surviving my finals.

So, what this program basically does is it tells you what day of the week was, is or will be from whatever date you input to the program. It also tells you if the year of your date was a leap year or not, and gives you the option to display leap years from your date to 100 years later.

It gives you the option to create a text document, named as you like or named as the day of the week of your date (.txt). It gives you the optionto write information inside of the document.

Another interesting thing that it does is that it can tell you  a cool fact about a leap year from 1900 to 2016, whichever one you choose.

To understand how it works better, run it on your computer or watch the demo run video (IN SPANISH) of the program here.

For this program I integrated my C++ knowledge learned on this course to be able to make it. In order for the program to work, I used:

  • If else statements.
  • While and do while statements.
  • Basic input and output (CIN, COUT)
  • For loops.
  • Arrays. Exampel of use: int leap_ar [] = {1904, 1908, 1912, 1916, 1920, 1924, 1928, 1932, 1936, 1940, 1944, 1948, 1952, 1956, 1960, 1964, 1968, 1972, 1976, 1980, 1984, 1988, 1992, 1996, 2000, 2004, 2008, 2012, 2016};
  • File handling and creation.
  • Writing on files.
  • Strings.
  • Basic algebra and operations.
  • etc…

Among other useful tools learned during this course.

Credit for the equation used in this program to calculate the day of the week goes to: http://www.tondering.dk/claus/cal/chrweek.php#calcdow”
Credit for the info on leap years goes to http://www.infoplease.

Archivo_000
Archivo_001

Continue reading “PROJECT: DATE FINDER 1.0”

#TC101 Course Review

I really enjoyed having this class. I think it helped me a lot to learn about programming logic in general, structure, syntax etc. I also learned a lot about the specific programming language C++, which will be really useful during my Mechatronics studies in the future. About transversal topics, I learned the usefulness of a hashtag in general, be it on Twitter or be it on Ken´s blog. I learned to blog, I learned to install and use Cygwin, to video record my screen with Screenscatify , the importance of Flowchartsand many other things that I may not recall at the moment.

I made two videos talking about my experience on this course. Pardon my accent  🙂

Yo soy 196. Palindromes and Lychrel numbers

ANITA LAVA LA TINA

RECONOCER

RACE CAR

Here you can take a look at My code on GitHub.

You should really check out Orlando´s Blog post.  You´ll learn how to do it perfectly.

 

First of all, I really have to thank Orlando Lara. Thank you for your time doing those amazing videos teaching us mortals about #WSQ11. Also many thanks to my teacher Ken Bauer, for his video explaining how to use BigInteger s on the program. You should really check out Ken´s video, cause it is kind of complex how to use and compile programs with this BigIntegers.

Basically those were all my sources to make this program. I once again thank Orlando, for teaching us how to use strings and bool functions. Before this program, I had never used them.

Following Orlando´s guide (sorry for saying it so much, but is the truth), I made my program to work with only two functions. One flips out each number of the sequence, using this:

BigInteger Num_reverse (BigInteger i){

string neto = bigIntegerToString(i);
neto = string(neto.rbegin(),neto.rend());
i = stringToBigInteger(neto);

return i;
}

It is a command to flip out the string, but what the function does first is convert once again the number from BigInteger to string (which we had already done the inverse process). Then it reverses the string and converts it back to a BigInteger using “stringToBigInteger()”. 

So this function is called inside the main, on a for loop that runs from the lower bound of the sequence provided by the user to the highest. SO IT FLIPS EACH AND EVERY NUMBER OF THE SEQUENCE. After this, with an if, it checks out if the flipped number is equal to the original number. If this  is true, the we just found

Continue reading “Yo soy 196. Palindromes and Lychrel numbers”

Quiz 6. Euclid.

Euclid was one of the great ancient greek guys. Among the stuff he invented was the algorithm bearing his own name.

This is a common algorithm used in computing. It is used to find the greatest common denominator of two numbers (GCD). If you want to learn more about this, you should totally check the explanation at Khan academy´s post.

Orlando´s code helped me a lot. You should totally take a look. First I tried to make the code using a do while loop. It was becoming really hard, until I saw Orlando´s code using recursion. It was way easier to code it this way .

Here you can see a picture of the code (anyways you can see it on github Here):

code_euclid

code_euclid

Link to my code on github.

Quiz 5

 

Finally, I switched from CodeBlocks to Cygwin and Notepad++.

For this quiz, we were required to make two programs. One had to verify if a word was a palindrome or not, and the other had to make the summatory  of all the numbers evenly divisible by three, from a list of numbers provided by the user.

The second problem was way easier for me than the first one, since I had never used strings in my life. After doing some research on strings, I tried my first version, which did not work. Today, Salvador Ibarra´s blog was updated with a really helpful video on the subject, in Spanish. Also, his code on github helped me a lot. So basically, thank you Salvador, I owe you one.

But the thing is not only to copy, but to understand, so here I´ll explain you my version of the palindrome program.

First of all, a palindrome is a word or a number that can be read normally or backwards and yoy get the same word. For example Anna, read it backward and it is the same word. 111 is a palindrome number.

In order to make a program to capable of deciding if a word is a palindrome or not, I had to use strings in C++. I made four strings and a string function.  Two were really important, string palabra and string backwards. On string palabra the program stores the word provided by the user, and on string backwards it stores it backwards.

The process made to store the word backwards was done with a for loop. The parameter to continue the for loop was the length of the string palabra, which I stored on an integer variable called largo. To get that value, you just write the name of the

for loop

Continue reading “Quiz 5”

Standard deviation calculator

THIS BLOGPOST IS  NOT DONE YET, BUT STILL YOU CAN ALREADY TAKE A LOOK AT THE CODE, WHICH IS AT THE END. For the task number ten of the semester, we were asked to create program that asks the user for 10 numbers. We were required to store those numbers in a list and to show the user the total, average and standard deviation of those numbers.

The easiest way to this was to create an array for those numbers. An array is just a group of numbers saved by the computer. You can acces any of those numbers WSQ10_functions1WSQ10_STDFfunctionsWSQ10_main

#include <iostream>
#include <cmath>

using namespace std;

int y;
char answer;

float SumaTotal(float arre [], int numNumeros){

float sum = 0;

for (int i = 0; i < numNumeros; i++){

sum += arre[i];
}
return sum;
}
float Average (float arra[], int numas){

float aver, suma = 0;

for (int c = 0; c < numas; c++){

suma = suma + arra[c];
}

aver = suma / numas;

return aver;
}
float STDF (float arre[], int numdenum){

float aver, sumaII, sumaIII = 0,sumaI = 0;
double stdfi;
for (int c = 0; c < numdenum; c++){

sumaI += arre[c];
}

aver = sumaI / numdenum;

for (int i = 0; i < numdenum; i++){

sumaII = arre[i] – aver;
sumaIII += pow((sumaII), 2);
}

stdfi = sqrt((sumaIII / numdenum ));

return stdfi;
}
int main (){

do{

cout << “Type the number of numbers that you want to have: “;
cin >> y;

const int numNumbers = y;

float x [numNumbers];

for (int i = 0; i < numNumbers; i = i + 1){
cout << “Provide the number ” << i + 1 << ” number: “;
cin >> x [i];
}
cout << “The total of your numbers is:

Continue reading “Standard deviation calculator”

Quiz 03

Today we had to do Quiz number 3. Problem number one was about the distance between two points on a cartesian plane. Number two was way harder. We had to make a program that would calculate the Fibonacci series of numbers till the number that the user inputs.

Problem number one was easy for me. I just used the equation of the distance between two points, which is the Pitagorean Theorem applied.

distance-between-two-points-formula

My translation to C++ language was:  d = sqrt(pow((c-a),2)+ pow((d-b),2)), a, b, c and d being parameters of my function, input by the user.

The second problem was the one that troubled me. The most important thing while solving any kind of problem, be it C++ or physics is to really understand what you are being asked. So, that was my frst step, to understand what a Fibonnacci series is. It is the sum of a number plus the next one, starting on 0. So the series would look like this:

0,1,1,2,3,5,8,13…

0+1 = 1, 1+1 = 2, 2+1 = 3, 3+2 = 5, 5+3 = 8, 8+5 = 13, 13+8 = 21;

To translate this to a command in C++ was hard for me. But I did it the next way:

#include <iostream>

using namespace std;

int n, fI = 0, fII = 1, f;

int fibonacci(int n){
for (int t = 1; t < n ; t++){
f = fI + fII ;
fI = fII;
fII = f;
}
return f;
}
int main(){
cout << “Provide the nth number of the Fibonacci list that you want to print: “<< endl;
cin >> n;
cout << “Your number is: ” << fibonacci(n);
}

I created a function called fibonacci, with 1 parameter (the number of the series that the user wanted to output). Inside the

Quiz03.jpg

Continue reading “Quiz 03”

Project! 2 DOF Robot Arm

So! I finally decided what my project for the semester wll be…

A two degrees of freedom robotic arm. I chose this project since the arm will require a lot of porgramming to work, an I´ll do it on C++. This project will be worked together with the project in Computer Drawing class.

A two degrees of freedom robotic arm is a machine simulating a human arm, but with only two “joints” or  places where it can bend or rotate.

The objective of the project, besides learnig A LOT will be the next one, as I stated it on my computer drawing document.

  • create an easy to use and easy to understand two degrees of freedom robotic arm, capable of lifting a maximum weight of one kilogram from a distance of 60 centimeters. An easy to replicate arm, with all its information free to use for everyone and after my first design is released, the code will be open sourced., as well as the design.

Here you can have a look at my first sketch of the project:sketch2

 

I did two toher sketches, have a look:

sketch1
sketch3

I chose the first one, since I think it´ll work better.

Since this is a blog about programming, about that is what I will keep you most updated on.

What I know is that I´ll program the servomotors with C++, through a Freedom by Freescale develpment platform (which I already have, thanks TEC) on the online tool Mbed. I did some similar programming last semester on a little line-following cart. 

I´ll keep you updated, now my project has to be approved by my proffesor- Thanks for reading.