#WSQ10 Babylonian Method 21/03/17 and WSQ10.cpp

--Originally published at Solving Problems with Programming

So in this twelve week class I started with doing this WSQ10 I started reviewing in creating and calling functions in C++.#Mastery06, #Mastery07, #Mastery16 Use of recursion for repetitive algorithms, #Mastery17 When to use what type of repetition in a program, #Mastery18 Creation and use of Arrays/ Vectors in C++. Futhermore, in this stage I have all the topics of the course from 1 to 20.

What I did for this numeric program is solving the problem to the user by creating a program with writing a function to calculate the square root of a number using the Babylonian method. You can search for that method, it will be easy to find. Hence, you can have it here in the survey that we did last week:

bab

Then, we need that this the function should receive a number and return floating point number. Obviously you should test your function, so create a main program that asks the user a value, calculates the square root and displays that.

Hence, the resources I need it to solve this program are here:

ken bauer

Similar code provided by Xochitl96

The following photograph shows the solution to this problem:

ba1

ba2

ba3

So at first I wrote the same structure of the program just did the same as what i did in Hello World: Second Class, Second Blog (Blog of the second class 12/01/17) and Hello World.cpp,  #WSQ01 Post Fun with Numbers 16/01/17 and WSQ1.cpp#WSQ02 Post Temperature 23/01/17 and WSQ02.cpp#WSQ03 Post Pick a Number 23/01/17 and WSQ03.cpp#WSQ04 Post Sum of Numbers 23/01/17 and WSQ04.cpp#WSQ05 Six Tutorial On To Functions 12/02/17 and WSQ05.cpp#WSQ06 Factorial Calculator 12/02/17 and WSQ06.cpp#WSQ07 Lists 03/03/17 and WSQ07.cpp, #WSQ08 Yo soy 196 11/03/17 and WSQ08.

444
Continue reading "#WSQ10 Babylonian Method 21/03/17 and WSQ10.cpp"

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."

Post of the weeks #6,7,8,9 and 10 what things I learned in these weeks ? And Index of Mastery Topics

--Originally published at Solving Problems with Programming

Picture of author

First let me tell you that  I learn and achieved all transversal topics and you can see it in the following link: Post of the week #3 what things i learned in this week #3 ? And Index of Mastery Topics

I also explain my project and formed a small team that corresponds of completing this ability to create C++ project in IDE and run inside the IDE and can be explained in my post My Project For the Course TC1017 and Expo Ing. Let’s code!

Futhermore, I am going to present the report of all the Mastery Topics achieved in this week:

  1. #Mastery01 Use of comments, achieved in: Post of the week #2 what things i learned in this week #2 ?
  2. #Mastery02 C++ Good Style coding conventions, achieved in: Post of the week #2 what things i learned in this week #2 ?
  3. #Mastery03 Basic types and their use, achieved in: Post of the week #2 what things i learned in this week #2 ?
  4. #Mastery04 Basic output (print), achieved in: Post of the week #2 what things i learned in this week #2 ?
  5. #Mastery05 Basic user input (text based), achieved in: Post of the week #2 what things i learned in this week #2 ?
  6. #Mastery06 Calling functions, achieved in: #Quiz03. Also here:#WSQ08 Yo soy 196 11/03/17 and WSQ08.cpp
  7. #Mastery07 Creating functions, achieved in: #Quiz03. Also here: #WSQ08 Yo soy 196 11/03/17 and WSQ08.cpp
  8. #Mastery08 Importing and using libraries, achieved in: Post of the week #1 what things i learned in this week #1 ? Also in #WSQ08 Yo soy 196 11/03/17 and WSQ08.cpp
  9. #Mastery09 Creating and using your own libraries (program with multiple files), achieved in: #Quiz03. Furthermore, also in here: #WSQ08 Yo soy 196 11/03/17 and WSQ08.cpp
  10. #Mastery10 Use of the conditional “if”,
    Continue reading "Post of the weeks #6,7,8,9 and 10 what things I learned in these weeks ? And Index of Mastery Topics"

WSQ09 :)

--Originally published at Tec Life

So, hello againnnn, this is the problem for this week:

Create a function that receives as parameter the name of a file (this would be a string value like data.txt) and your function counts the number of lines and the number of characters in the file which it returns as a single value (but with two values). You will want to look at how to create/define and return a struct value from a function and how to open and read text files line by line.

So, how do I start???

First of all I include to new libraries :

  1. fstream: To be able to read a file.
  2. String: To use my get line function.

Then I declare my to variables “palabras and lineas” with a value of cero, then I make that my program will make a text file called texto.txt and then I put my if stream because we are going to put things on the program in other words “if = in, ofs= out”.

Then I make to open my file with open and the name of my file, and what would happened if it fail and to do that while is open and its going to add one value to lineas and palabras.

I really don’t know how to explain it right because if you don’t know so much things you will never know what I am doing. So read your textbook and search information on internet about this problem, because it was a hard one.

See you laterrrrr.

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

Image from: https://clipartfest.com/categories/view/382647a840319bed4aa74f8b873e6b3c85a45d91/open-book-with-words-clipart.html


WSQ09 :)

--Originally published at Tec Life

So, hello againnnn, this is the problem for this week:

Create a function that receives as parameter the name of a file (this would be a string value like data.txt) and your function counts the number of lines and the number of characters in the file which it returns as a single value (but with two values). You will want to look at how to create/define and return a struct value from a function and how to open and read text files line by line.

So, how do I start???

First of all I include to new libraries :

  1. fstream: To be able to read a file.
  2. String: To use my get line function.

Then I declare my to variables “palabras and lineas” with a value of cero, then I make that my program will make a text file called texto.txt and then I put my if stream because we are going to put things on the program in other words “if = in, ofs= out”.

Then I make to open my file with open and the name of my file, and what would happened if it fail and to do that while is open and its going to add one value to lineas and palabras.

I really don’t know how to explain it right because if you don’t know so much things you will never know what I am doing. So read your textbook and search information on internet about this problem, because it was a hard one.

See you laterrrrr.

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

Image from: https://clipartfest.com/categories/view/382647a840319bed4aa74f8b873e6b3c85a45d91/open-book-with-words-clipart.html


#WSQ08 Yo soy 196 11/03/17 and WSQ08.cpp

--Originally published at Solving Problems with Programming

PICTURE OF ACTOR

So in this nine week class I started with doing this WSQ09. I started reviewing in creating and calling functions in C++.#Mastery06, #Mastery07, #Mastery16 Use of recursion for repetitive algorithms, #Mastery17 When to use what type of repetition in a program, #Mastery18 Creation and use of Arrays/ Vectors in C++. Futhermore, in this WSQ assignment we have mostly all the topics of the course from 1 to 20.

What I did for this numeric program is solving the problem to the user by creating a program that asks the user for two pieces of data:

  • The lower bound of the sequence
  • The upper bound of the sequence
Then you check the values from the lower bound (inclusive) to the upper bound (inclusive) and make a report of them. During the analysis of each number, if a Lychrel number is found it should be reported immediately with something like “Found a Lychrel number: 196”
The report must show:
  • The range of numbers analysed (lower to upper bound)
  • The number of natural palindromes (no addition to inverse needed)
  • The number of non-Lycherels encountered (become palindromes)
  • The number of Lycherel number candidates (that did not converge to palindrome)

Since you will not be able to prove that a number is Lycherel (since you cannot computer forever to check), our definition for a Lycherel candidate will be if a number does not converge after 30 iterations of applying the addition to the inverse.

To get this working well, you will need support for Big Integers. So I need to use that library that my teacher  ken bauer has given to me, here you go:

This link is for Library of Big Integer provided by ken bauer

Hence, the resources I need it to solve this program are here:

ken bauer

Similar code provided for

wsq8v2
wsq8v3
wsq8v4
wsq8v5
wsq8v6
wsq8v7
wsq8v8
yo soy 196
Continue reading "#WSQ08 Yo soy 196 11/03/17 and WSQ08.cpp"

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


#WSQ09 Multipart Data and Files 10/03/17 and WSQ09.cpp

--Originally published at Solving Problems with Programming

PICTURE OF ACTOR

So in this nine week class I started with doing this WSQ09. I started reviewing in creating and calling functions in C++.#Mastery06, #Mastery07, #Mastery16 Use of recursion for repetitive algorithms, #Mastery17 When to use what type of repetition in a program, #Mastery18 Creation and use of Arrays/ Vectors in C++.

Futhermore in this assignment we have two new mastery topics covered #Mastery19 Creation and use of strings and #Mastery21 Reading and writing of text files.

What I did for this numeric program is solving the problem to the user by writing a function that receives as parameter the name of a file (this would be a string value like data.txt) and this function counts the number of lines and the number of characters in the file which it returns as a single value (but with two values). I will want to look at how to create/define and return a struct value from a function and how to open and read text files line by line.

Hence, the resources I need it to solve this program are here:

ken bauer

How to convert string to char

C++ Tutorial for Beginners 43 – How to Read from a .txt file using C++

The following photograph shows the solution to this problem:

wsq9v1

wsq9v2wsq9v3wsq9v4

Picture of author

So at first I wrote the same structure of the program just did the same as what i did in Hello World: Second Class, Second Blog (Blog of the second class 12/01/17) and Hello World.cpp,  #WSQ01 Post Fun with Numbers 16/01/17 and WSQ1.cpp#WSQ02 Post Temperature 23/01/17 and WSQ02.cpp#WSQ03 Post Pick a Number 23/01/17 and WSQ03.cpp#WSQ04 Post Sum of Numbers 23/01/17 and WSQ04.cpp#WSQ05 Six Tutorial On To Functions 12/02/17 and WSQ05.cpp#WSQ06 Factorial

charactes
Continue reading "#WSQ09 Multipart Data and Files 10/03/17 and WSQ09.cpp"

#WSQ07 Lists 03/03/17 and WSQ07.cpp

--Originally published at Solving Problems with Programming

PICTURE OF ACTOR

So in this eight week class I started with doing the survey of mid semester where I gave ideas in order to improve this course and this and this WSQ07. I started reviewing in creating and calling functions in C++. #Mastery06, #Mastery07, #Mastery16 Use of recursion for repetitive algorithms, #Mastery17 When to use what type of repetition in a program and #Mastery18 Creation and use of Arrays/ Vectors in C++.

What I did for this numeric program is solving the problem to the user by writing 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.Futhermore, Once you have this working, change it so that users keep giving you values until they signal “no more values”. How would you implement this and in particular for the C++ group, how to you deal with an unknown size to your array during compilation?

The quantity of the value depends of the quantity of the type float variable that has only 32 bits of leght, therefore you need a new library in order to increase the value of numbers called Biginteger.hh but I am going to add it in the next WSQ08 called Yo soy 196. Next, to deal with an unknown size of my array during compilation we need to ask the user the number of that size and save it in a variable n.

The resources I need it to solve this program are here:

ken bauer

Similar code made by Eduardo Torres

C Programming Tutorial: Functions (Call By Value, Reference,passing Arrays to function)

The following photograph shows the solution to this problem:

wsq7v2

wsq7v3

wsq7v4wsq7v5

wsq7v6

Picture of author

So at first I wrote the same structure of the program just did the same as

s1
s2
s3
s4
s5
Continue reading "#WSQ07 Lists 03/03/17 and WSQ07.cpp"