--Originally published at Loading…
Tag: #Mastery19
Multipart Data & Files
--Originally published at Loading…
Hi!! Is almost the ending of this semester and I promised not to leave everything to the last minute… but here I am… doing all in the last minute.
Today I’m going to explain how I did the #WSQ09. To make this program I asked for help to my friend Jenifer Romero, she explained me everything, but the problem was that we did it on her Mac, so… I had to make some arrangements in order for it to work in my Windows computer.
This is what we had to do:
So for this assignment I would like to see you 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
The first thing I did was to add the two necessary libraries <fstream> & <string>. Then, for make the “it returns as a single value (but with two values)” part, I added a struct that I called datos, which stores two int, l (for lines) and c (for the characters). Next, in my function (func) which receives the string url (or ruta) and called the struct. After that I wrote ifstream archivo(ruta.c_str(), ios::in) it associates it with the file name and opens it. I established my variables (at the final I don’t use the char car, ‘cause Ken helped me to do the same with less), and wrote a while for do the things until the
Continue reading "Multipart Data & Files"Where is my banana?
--Originally published at Adal´s Blog
Where is my banana?
--Originally published at Adal´s Blog
Dovahkiin, Dovahkiin, naal ok zin los vahriin.. (#WSQ09)
--Originally published at Programming Path
The assignment of #WSQ09 was the next one:
So for this assignment I would like to see you 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
This for sure was a new topic. It was thanks to Ken’s Disciple 01‘s blog that I could understand this task.
First I needed to make a text file (.txt) so I wrote a Skyrim quote. It is from an ancient dragon and I got attached to him because it was the only friendly dragon, but anyway here is the text:
Then we had to make the program open the file and count how many characters and lines does it has. Then print it out.
Thanks for reading.
Yo soy 196
--Originally published at Solving problems with programming
In this homework what we need to count in a range of numbers how many palindromes are, how many numbers aplying a certain formula convert into palindromes, and how many numbers are lycheral numbers. A palindrome is a number that reading it from left to right and right to left is the same number. A palindrome a nonpalindrome can be converted into one with an easy formula, flip the order of the the values and add it to the orginal value, the result will do a palindrome. Example: 100 + flip(001) = 101. The result of the example is a palindrome so the formula works. There are numbers that even with the formula don’t become palindromes. Those are called lychrel numbers. To identify a lucheral number we apply the formula 30 times, if we already applied the formula 30 times and the number is not a palindrome it is because is a lychrel number.
In this code we use an especial library called BigInteger.hh that it is an aditional library besides the ones that are alredy insalled in our computer. To add it you have to put all the files from the library in the location of you cpp file and use the command make to compile it. Also the including the library you have to use (” “), instead of (<>), you will see it in the code example code.
In this homework we cover #Mastery19 with the use of strings. Strings are also variables and we include the library <string> to use the lenght() function that works to count the number of characters of a string. In this program we count the number of characters to be able to flip a number and apply the formula of palindromes.
Another #Mastery15 that we cover with nested loops. In
Continue reading "Yo soy 196"Post of the weeks #11,12,13,14,15 and 16 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:
- #Mastery01 Use of comments, achieved in: Post of the week #2 what things i learned in this week #2 ?
- #Mastery02 C++ Good Style coding conventions, achieved in: Post of the week #2 what things i learned in this week #2 ?
- #Mastery03 Basic types and their use, achieved in: Post of the week #2 what things i learned in this week #2 ?
- #Mastery04 Basic output (print), achieved in: Post of the week #2 what things i learned in this week #2 ?
- #Mastery05 Basic user input (text based), achieved in: Post of the week #2 what things i learned in this week #2 ?
- #Mastery06 Calling functions, achieved in: #Quiz03. Also here:#WSQ08 Yo soy 196 11/03/17 and WSQ08.cpp
- #Mastery07 Creating functions, achieved in: #Quiz03. Also here: #WSQ08 Yo soy 196 11/03/17 and WSQ08.cpp
- #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
- #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
- #Mastery10 Use of the conditional “if”, Continue reading "Post of the weeks #11,12,13,14,15 and 16 what things I learned in these weeks ? And Index of Mastery Topics"
#WSQ12 Estimating e 15/04/17 and WSQ12.cpp
--Originally published at Solving Problems with Programming
So in this fourteen week class I started with doing this WSQ12 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++. Furthermore, in this stage I have all the topics of the course from 1 to 22.
What I did for this numeric program is solving the problem to the user by creating a program with writing this assignment where I will estimate the mathematical constant e. I should create a function called calculuate_e which receives one parameter called precision that should specify the number of decimal points of accuracy.
I will want to use the infinite series to calculate the value, stopping when the accuracy is reached (previous and current calculation are the same at the specified accuracy).
Hence, the resources I need it to solve this program are here:
For doing this tutorial you need to do the factorial, therefore you need to see my tutorial #WSQ06 Factorial Calculator 12/02/17 and WSQ06.cpp
ken bauer
And the next picture shows us how the number e is calculated with infinite series and I will do this infinite serie in c++
The following photograph shows the solution to this problem:
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 Continue reading "#WSQ12 Estimating e 15/04/17 and WSQ12.cpp"
#WSQ11 Go Bananas 15/04/17 and WSQ11.cpp
--Originally published at Solving Problems with Programming
So in this fourteen week class I started with doing this WSQ11 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++. Furthermore, in this stage I have all the topics of the course from 1 to 22 including #Mastery22 Matrixes and vectors because in this code I use a matrix with a dimension of 1.
What I did for this numeric program is solving the problem to the user by creating a program with writing 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.
Hence, the resources I need it to solve this program are here:
ken bauer
Video to convert higher to lower cases from the .txt file
The following photograph shows the solution to this problem:
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. Continue reading "#WSQ11 Go Bananas 15/04/17 and WSQ11.cpp"
Quiz
--Originally published at Loading…
Hi! I know it pass a long time without posting anything, sorry I’m in that point of the semester trying to save it.
And I know maybe this post would be more useful the last week, before the partial, but… I hope it could help you.
1. Distance again.
Actually I’ve already explain this code, and I do the same in this quiz, so I’m not going to explain this one, but here is my code:
2. T’s pyramid
This one was kind of difficult because one of my functions was wrong, but technically it’s veryyyy easy.
I only use the library <iostream>, but I used two functions. The first one was for print the T in each line, for this I used an if and a for, which simply is adding one T in each line of the pyramid. The second function is for print how many lines must have the pyramid, so I use two for, one to increase f (fila) while it’s smaller than n(the number that the user enter). And the other one to decrease f, when it is the same as n and until f is 1.
3. n!
This one I’ve already explained too, so like the first one, I’m not going to explain it. The only difference is that I made this code more simply like the one that is in the link.
4. Average list
This one was kind of easy. First I established the libraries <iostream> and <cmath> and as always put the using namespace std;. Then, I created a float function named promedio_lista that receives the sum and returns the prom. Next, in my int main I established two kind of variables, in the float I put the array cal[7] (this ‘save’
Continue reading "Quiz"