WSQ 11 “GO BANANAS”

--Originally published at blog de Horacio

What to do:

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.

progress:

Para contar palabras en un archivo de texto es necesario considerar varias cosas:

La palabra podría tener letras mayúsculas y minúsculas en ella, o podría estar junto a otra palabra sin ningún espacio, por lo que la función “dividir” no ayudará mucho.

Captura de pantalla 2017-05-07 a la(s) 21.19.13

Como puede ver, nuestro big_string tiene la palabra “bananas”, pero no todos los bananos tienen la misma estructura. Así que primero de todo. Convertiremos cada palabra en minúscula (línea 3).

Para dar más flexibilidad al programa, convertimos las letras de BaNana en minúsculas.

Después de eso, lo que haremos es buscar la palabra que verifica cada carácter, y mientras la cadena no está vacía, el programa lo comprobará y encontrará todos los plátanos.

Captura de pantalla 2017-05-07 a la(s) 21.21.27.png


BANG!ana

--Originally published at Ken's Disciple 01

Picture by Pixabay Pixabay

Hi guys in this WSQ 11 Fabrizzio Cortez helped me a lot with his video.

Pretty much this are the steps:

  1. Import the library of fstream
  2. First function:  for loop where if i is smaller than the length then with the function to lower the program will change all the letters to lower case.
  3. Infinite loop that only stop if you break it and in this I find the number of bananas of each line, and the program saves that info.
  4. break: ends the infinite loop
  5. This function will return the number of bananas in each line
  6. Next function:  open the text file, read it and  made a counter that counts the accumulating bananas in each line of the text
  7. Finally in the int main: final counter, this will use the last functions and the return values will be returned.

 

Code:

Captura de pantalla 2017-05-02 a la(s) 18.23.31.png

Captura de pantalla 2017-05-02 a la(s) 18.23.44.png

Captura de pantalla 2017-05-02 a la(s) 18.23.53.png

Captura de pantalla 2017-05-02 a la(s) 18.26.56.png

Captura de pantalla 2017-05-02 a la(s) 18.23.16.png

Code at GitHub

L.out


Where is my banana?

--Originally published at Adal´s Blog




No soy muy fan de trabajar con string, pero debido a que tengo que saber trabajar con ellas. y que lo veo como un reto personal, es que he decidido hacer las actividades relacionadas con strings, así que comencemos  


Como ya lo habia comnetado antes, no se me da muy bien los strings, por eso acudi al blog de Fabricio y al de María José para tener un poco mas de ayuda



Al final inserte unos caracteres ascii con la palabra banana y una banana debajo que me encontré en Internet, se me hiso que quedaba a la situación, solo que el compilador se volvio loco con unos caracteres y no supo como imprimir algunas lineas ;(

  

Paginas de ayuda:



Where is my banana?

--Originally published at Adal´s Blog




No soy muy fan de trabajar con string, pero debido a que tengo que saber trabajar con ellas. y que lo veo como un reto personal, es que he decidido hacer las actividades relacionadas con strings, así que comencemos  


Como ya lo habia comnetado antes, no se me da muy bien los strings, por eso acudi al blog de Fabricio y al de María José para tener un poco mas de ayuda



Al final inserte unos caracteres ascii con la palabra banana y una banana debajo que me encontré en Internet, se me hiso que quedaba a la situación, solo que el compilador se volvio loco con unos caracteres y no supo como imprimir algunas lineas ;(

  

Paginas de ayuda:

Bananas Bananas Bananas

--Originally published at my programming blog

What I needed to do:

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.

Thanks to this tutorial and this post.

So what I did was:

  1. I imported the library of fstream
  2. In the first function I did a for loop where if i is smaller than the length then with the function to lower the program will change all the letters to lower case.
  3. I also did an infinite loop (That’s why it has a 1 as a condition) this loop will only stop if you break it and in this I find the number of bananas of each line, and the program saves that info.
  4. Then at the end there is a break to end the infinite loop
  5. This function will return the number of bananas in each line
  6. Then in the next function I open the text file and read it and I made a counter that counts the accumulating bananas in each line of the text
  7. Finally in the int main I have a final counter and this will use the last functions and the return values will be returned.

Screen Shot 2017-05-02 at 1.34.20 AMScreen Shot 2017-05-02 at 1.34.28 AMScreen Shot 2017-05-02 at 1.34.37 AMScreen Shot 2017-05-02 at 1.34.46 AM

Screen Shot 2017-05-02 at 1.34.01 AM.png

My code in Github: https://gist.github.com/mariasantoyodl/31c998d729a8e608a0abfe31e59cf8e5


Bananas!

--Originally published at Programming course

So this assignment was longer than I expected but it was fun

here is what we had to do:

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.

And my codeWSQ11.png


Homework 11: Go Bananas

--Originally published at Let's CODE

Now we are going to make a program that can find the quantity of BANANAS present in a text file. The word “banana” can be writen in any way, that’s why I opted for converting all letter in the document to lower case. I set a vector called BANANA with a size of 6, where … Continue reading Homework 11: Go Bananas