Go bananas

--Originally published at PZ

 

Ok, for me this was very difficult because I thought it would be much easier than that, I though that it was going to be very similar to a quiz that we did  where we had to find the char o, so I used that quiz as a base.

But then I realize that I will need to find  something that traduce the text from BanNana or baNNAna to banana so I found this blogs.

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

In the video the only difference is that he uses toupper.

Then I was stuck because I did not know what to do next to find the word banana, but then I find Fabrizzio Cortez blog who is a mechatronic engineer that did a very good job and uplouded high quality reviews. In the video I noticed that I must use .find which help us to find the word that we want, and also break to end the infinite loops.

In my code I wrote some notes: https://www.dropbox.com/s/be47iyu197epf64/wsq11.cpp?dl=0


WSQ11-Go Bananas

--Originally published at Ernesto's Computing Works

Este es el trabajo wsq numero 11 llamado go bananas, ya veran porque. Para ese programa debia crear una funcoion llamada find_bananas la cual recibiera un solo parametro llamado filename y fuera una variable con valor string, yregresara como valor final un numero positivo que representara el numero de veces que la palabra “banana” es encontrada en el archivo de texto. Esta palabra puede funcionar con cualquier caso en como esta palabra estuviera escrita ademas que no hubiera ningún problema con que estuvieran pegadas las palabras bananas. Para este programa tuve que hacer un archivo extra de puro texto para probar mi programa, y esto decia mi archivo de texto:

bananas bananadas bananas banasbanabdana bananas bannasasd bananas bananas bananababananas banabananas bananas
banannas nbasban bananas bananas bannasb nnasbbannbaanabs bananas estan bien ricas las bananas bananas por todas partes

En este trabajo también me base en el programa de dos alumnos

este es uno de ellos: https://mariasprogramingblog.wordpress.com/2017/05/02/bananas-bananas-bananas/

En si se me hizo muy complicado este programa y no me salia bien ademas que me costaba trabajo entenderlo. Lo que hice fue crear dos funciones, una para que leyera las lineas una por una buscando la palabra banana, y otra para leer el archivo de texto y por ultimo un main para que solamente desplegara el resultado de las funciones.

Este es mi programa y el resultado después de correrlo:

Screenshot 2017-10-27 17.32.08

Screenshot 2017-10-27 17.32.18

 

También en este programa abarco un mastery topic numero #11 el cual dice que se usar la función else en un conditional, que representa lo que hará el programa den caso de que no se cumpla la condición que pusiste.

 


WSQ11 – Go Bananas

--Originally published at Solving problems with programming

For this assignment I´ve to learn, again, how to use masterytopic number21, because for me it was to difficult to understand how to count and determinated the numbers of times that one word appear in the text

Also I´ve to read more post like the post of one good programmer and IMT, Juan Carlos Ron´s blog, after read i have more clues of where to start but for more questions I´ve to visited him and drink a cup of coffee with him to started to programm together.

You can see my code here, it has some errors but i would fix them: https://gist.github.com/jesuscmadrigal/d75578ad4fa94ff91a7ba37f8e16e58b

Haga click para ver el pase de diapositivas.

Go Bananas

--Originally published at RON

Estuvo muy divertido este WSQ y gracias a la ayuda de mi compañero Victor Castillo Madrigal puede elaborarlo con éxito. Abajo dejo mi código y el link del blog de Victor para que lo chequen, esta muy padre, de igual modo incluyo otras fuentes que consulte.

Temas de dominio:

Creación y uso de cadenas

Haga click para ver el pase de diapositivas.

Blog Victor:

https://victorcastillosite.wordpress.com/2017/10/27/wsq10/comment-page-1/#comment-11

Fuentes: 

https://a01634847.wordpress.com/2017/10/27/decimo-primer-programa/comment-page-1/#comment-8

Código .cpp:

https://drive.google.com/a/itesm.mx/file/d/0BwFGq6oJuVvVM1VpQnhkcHhmWWs/view?usp=sharing

 


WSQ11

--Originally published at Victor´s Spot

I have to admit that this task it was hard because I don´t dominate the fact of making list but step by step with each WSQ I am improving the way I code my programs. The WSQ11 requires to create a list and what we had to do was:

“Write a function called find_bananas which receives a single parameter called filename (a string) and returns a positive integer which is the number of times the word (string) “banana”  (or “BANANA” ) is found in the file. The banana can be any case (‘BaNana’ or ‘BANANA’ or ‘banana’, etc) and they can be “stuck together” like “banAnaBANANA” (that counts as two). Create your own test file (plain text) to check your work.” (Bauer, 2017)

In the creation of the function I discover a lot of funny things that I can do with the code but I decided to keep it classy.

I believe I developed the following mastery topics from kenscourses.com

  1. Reading and writing of text files
  2. Use of loops with “for”

The first may not be fully covered but partially, yes

WSQ11 I want to share with you a little poem about the code:

It seems we can now count bananas

But we can´t reach our pajamas

But soon we can be at the Bahamas

You can download my code here:


WSQ11 – Bananas!

--Originally published at BRENDA

Ind this assignment I learnt how to find a specific string in a file, in this case the word banana. I used the function line.find(“banana”).

First I made the function work by searching only for the word banana, with lowercase. I made a loop inside of a loop so that if the a word banana was found in a line it wouldn’t just jump right to the next line, instead it would keep looking in the same line until all the bananas were found.

When the code worked I added a new function called transform to convert all the strings in the file to lowecases. This way, it wouldn’t matter if the word was written as Banana or banAna, because it would be converted to just “banana”.

This is the function transform:

transform(line.begin(),line.end(),line.begin(), (int (*)(int))tolower)

Here is my code:

https://github.com/brendaruizt/TC1017/blob/master/banana.cpp

banana.PNG