WSQ 11 – Finding and counting a word in a text

--Originally published at GTO

This time I made a program that looks for a word in a text file and counts how many times does this word appears in the file. I found this program very similar to the last one I did for the WSQ 9 because it involved working with text documents in C++ too.

I first made the program just looking for the word banana when it was written just like that and then i realized that I need to adjust the program for looking also for banana when it is writed in a different way like BanaNa o BANaNa so I looked for information and I found the function that convert the file to lowercase and after that I made the count.

Screen Shot 2017-11-11 at 11.34.31 AM

You can find my full code here:

https://github.com/getorres99/TC1017-Fall-IMT-GTO/blob/master/WSQ11Findwords.cpp

 

The normal consult book: “How to Think Like a Computer Scientist, C++ Version”, Downey, Allen B. 2012.

Some information about the fstream library:

http://www.cplusplus.com/reference/fstream/fstream/

Tolower function:

http://www.cplusplus.com/reference/cctype/tolower/

#WSQ11#teclife

 

 

WSQ 11 – Finding and counting a word in a text

--Originally published at GTO

This time I made a program that looks for a word in a text file and counts how many times does this word appears in the file. I found this program very similar to the last one I did for the WSQ 9 because it involved working with text documents in C++ too.

I first made the program just looking for the word banana when it was written just like that and then i realized that I need to adjust the program for looking also for banana when it is writed in a different way like BanaNa o BANaNa so I looked for information and I found the function that convert the file to lowercase and after that I made the count.

Screen Shot 2017-11-11 at 11.34.31 AM

You can find my full code here:

https://github.com/getorres99/TC1017-Fall-IMT-GTO/blob/master/WSQ11Findwords.cpp

 

The normal consult book: “How to Think Like a Computer Scientist, C++ Version”, Downey, Allen B. 2012.

Some information about the fstream library:

http://www.cplusplus.com/reference/fstream/fstream/

Tolower function:

http://www.cplusplus.com/reference/cctype/tolower/

#WSQ11#teclife

 

 


Final Project Idea

--Originally published at GTO

For the final project I’m going to work with Rodrigo Valdez and we plan to do an arduino project, we have looked for ideas in different web pages and based on our experience and we decide that we are going to do a proximity sensor, for this project we need an arduino, a protoboard, the sensor and an output device that we are still thinking about between our options, the possibilities are LEDs that turn on at different speeds depending on the proximity or use a display to show how far the object is from the sensor.


Final Project Idea

--Originally published at GTO

For the final project I’m going to work with Rodrigo Valdez and we plan to do an arduino project, we have looked for ideas in different web pages and based on our experience and we decide that we are going to do a proximity sensor, for this project we need an arduino, a protoboard, the sensor and an output device that we are still thinking about between our options, the possibilities are LEDs that turn on at different speeds depending on the proximity or use a display to show how far the object is from the sensor.

Yo soy 196, Lychrel numbers in C++

--Originally published at GTO

This program ask the user for two numbers, a lower bound and an upper bound and evaluate all the numbers between, looking for palindromes and Lychrel numbers which are the ones that do not form a palindrome after successive additions to their inverse.

The report of the program shows the natural palindromes, how many non-Lychrel and how many Lychrel number candidates are between the to bounds.

 

Screen Shot 2017-10-25 at 4.26.22 PMScreen Shot 2017-10-25 at 4.29.43 PM

Here is my full code:

https://github.com/getorres99/TC1017-Fall-IMT-GTO/blob/master/yosoy196.cpp

You can find more about the program and the BigIntegers library here: https://kenscourses.com/tc1017fall2017/instructor/wsq08-yo-soy-196-2/

The normal consult book: “How to Think Like a Computer Scientist, C++ Version”, Downey, Allen B. 2012.

#WSQ08#teclife


Square Root of a Number with Babylonian Method in C++

--Originally published at GTO

This program calculates the square root of a number with the babylonian method, what this does is finding the result by approximation.

I obtained the formula of Babylonian method from: https://en.wikipedia.org/wiki/Methods_of_computing_square_roots

Here is my code and program working:

Screen Shot 2017-10-25 at 3.52.14 PM

And here is my full code:

https://github.com/getorres99/TC1017-Fall-IMT-GTO/blob/master/WSQ10.cpp

The normal consult book: “How to Think Like a Computer Scientist, C++ Version”, Downey, Allen B. 2012.

#WSQ10#lists#teclife


Yo soy 196, Lychrel numbers in C++

--Originally published at GTO

This program ask the user for two numbers, a lower bound and an upper bound and evaluate all the numbers between, looking for palindromes and Lychrel numbers which are the ones that do not form a palindrome after successive additions to their inverse.

The report of the program shows the natural palindromes, how many non-Lychrel and how many Lychrel number candidates are between the to bounds.

 

Screen Shot 2017-10-25 at 4.26.22 PMScreen Shot 2017-10-25 at 4.29.43 PM

Here is my full code:

https://github.com/getorres99/TC1017-Fall-IMT-GTO/blob/master/yosoy196.cpp

You can find more about the program and the BigIntegers library here: https://kenscourses.com/tc1017fall2017/instructor/wsq08-yo-soy-196-2/

The normal consult book: “How to Think Like a Computer Scientist, C++ Version”, Downey, Allen B. 2012.

#WSQ08#teclife

Counting Characters and Lines from a textile in C++

--Originally published at GTO

This program is able to open a file and count how many lines a how many characters exist in that file, to make this work the first thing is open a file which is done in this part:

datafile.open(filename);
while(getline(datafile,linea)){
lnstep++;
charCount += linea.length();
}

also that part is in charge of counting the characters and lines. Basically there is where everything happens and the other part of the code is for ask the input of file name, closing the file, printing, etc.

Hope this is useful for you.

Screen Shot 2017-10-25 at 2.58.30 PM

And here is my code:

https://github.com/getorres99/TC1017-Fall-IMT-GTO/blob/master/WSQ9.cpp

Sources:

I needed to look for information about opening and manipulating text files in C++, i found some useful stuff here: http://www.cplusplus.com/forum/beginner/8388/

and in this video:

The normal consult book: “How to Think Like a Computer Scientist, C++ Version”, Downey, Allen B. 2012.

https://www.programiz.com/cpp-programming/examples/standard-deviation

#WSQ09#teclife


Square Root of a Number with Babylonian Method in C++

--Originally published at GTO

This program calculates the square root of a number with the babylonian method, what this does is finding the result by approximation.

I obtained the formula of Babylonian method from: https://en.wikipedia.org/wiki/Methods_of_computing_square_roots

Here is my code and program working:

Screen Shot 2017-10-25 at 3.52.14 PM

And here is my full code:

https://github.com/getorres99/TC1017-Fall-IMT-GTO/blob/master/WSQ10.cpp

The normal consult book: “How to Think Like a Computer Scientist, C++ Version”, Downey, Allen B. 2012.

#WSQ10#lists#teclife

Counting Characters and Lines from a textile in C++

--Originally published at GTO

This program is able to open a file and count how many lines a how many characters exist in that file, to make this work the first thing is open a file which is done in this part:

datafile.open(filename);
while(getline(datafile,linea)){
lnstep++;
charCount += linea.length();
}

also that part is in charge of counting the characters and lines. Basically there is where everything happens and the other part of the code is for ask the input of file name, closing the file, printing, etc.

Hope this is useful for you.

Screen Shot 2017-10-25 at 2.58.30 PM

And here is my code:

https://github.com/getorres99/TC1017-Fall-IMT-GTO/blob/master/WSQ9.cpp

Sources:

I needed to look for information about opening and manipulating text files in C++, i found some useful stuff here: http://www.cplusplus.com/forum/beginner/8388/

and in this video:

The normal consult book: “How to Think Like a Computer Scientist, C++ Version”, Downey, Allen B. 2012.

https://www.programiz.com/cpp-programming/examples/standard-deviation

#WSQ09#teclife