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


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

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


Fibonacci

--Originally published at Tec Life

So the problem was make to a program to do a fibonacci serie, so in order to do it I search on internet what a fibonacci serie is, and I found that is a serie that sum the two last number and converted in a new one like 2 + 3 = 5 then the next number will be 5 + 3 = 8 and like that until ends, so in order to not crash my computer I put in the main that the user write how many digits the serie would have :).

I made two programs that does the same thing, the only deference is that one uses functions and the other not.

In the program with the function I start writing my function starting on 0 that in case that the user type 0 or 1 is going to return me that number, and in case that the condition doesn’t be true then is going to return me the number – 2 + the number -1 making a serie, but that only is going to one time, so I use a do while to print all the values of the serie, then I use a for to make all the serie appears and thats all :).

And in the other program because the first to number there are not going to repeat I printed first with a cout and then I use my for to start and finish the serie depending the conditions.

And here is and image of jumping corgi in the snow :).

funnocaptura-de-pantalla-2017-03-02-a-las-09-02-46

Have fun

Image from: http://www.artifexbalear.org/img/fibonac8g.jpg and  http://buzzsharer.com/wp-content/uploads/2015/06/jumping-corgi-winter.jpg

 


Quiz 6

--Originally published at Tec Life

In order to do this quiz I search the information in one site: http://www.cplusplus.com/reference/

We have to solve 5 problems; the first one was about correcting one program and run it, so I use two new libraries in order to solve the program and start testing and rewriting the program, and the final result was this:captura-de-pantalla-2017-02-13-a-las-09-08-45captura-de-pantalla-2017-02-13-a-las-09-09-01

The second problem was about writing a program to read in a character, an integer, and a float, and print out the values, then cast to other types; so that the interaction with the user is something like the following:

captura-de-pantalla-2017-02-22-a-las-21-25-57

captura-de-pantalla-2017-02-22-a-las-21-26-06

The next program was only about to the following pattern:

                        C
                      i   I
                    s       s
                  b           b
                e               e
              s                   s
            t s e b s i C i s b e s t

 

So the only thing that I have to do was print the letters in that order and that was allcaptura-de-pantalla-2017-02-13-a-las-09-42-22

For the fourth problem they ask us to write a program to read three ints and to print them in ascending order, so the most easy thing to do was using a lot of if and else to solve this problem:captura-de-pantalla-2017-02-22-a-las-21-31-32

captura-de-pantalla-2017-02-22-a-las-21-31-43

And the last problem they ask us to write a program given the following rules, write a program to read a year (4 digit integer) and tell whether the given year is/was a leap year.

  1. There were no leap years before 1752.
  2. If the year divides by 400 then it is a leap year.
  3. All other years that divide by 100 are not leap years.
  4. All other years that divide by four are leap years.

So I use the main if as 1752 because if that wasn’t true then the year will be normal, the I use another if to say the conditions when the year will be

captura-de-pantalla-2017-02-23-a-las-08-29-54
captura-de-pantalla-2017-02-23-a-las-08-30-04
Continue reading "Quiz 6"