Our project- HANGMAN.

--Originally published at Alexa

I made this project with the help of Lourdes Manzanilla. It’s a pretty hangman game that gives you 7 tries and asks you to choose between 3 cathegories. The most difficult part was turning the hyphens into letters in case they were right. The funniest part was making the hangman. Thanks to this project we learnt a lot of new things and we challenged ourselves.

ASCII art: https://www.ascii-code.com/ascii-art/animals/

https://www.ascii-code.com/ascii-art/food-and-drinks/

http://www.chris.com/ascii/index.php?art=food%20and%20drink/apples

http://patorjk.com/software/taag/#p=display&f=Graffiti&t=Type%20Something%20

Youtube (some videos that helped): https://youtu.be/QSfqsJYA6a8

Thanks to Teacher Ken for this course and to all my classmates.

Here is the code:     hangman

Here is the output: project


WSQ 13- SciLab

--Originally published at Alexa

Here I played with some of the stuff that came in the manual. I realized that it is actually a very good tool to solve problems more easily. You can do a lot of things you normally do on C++ but this is better and less silly. Here I used #masterytopic22 #masterytopic23 and #masterytopic24.


WSQ 12- Estimating e.

--Originally published at Alexa

doggyywsq12

My code:

#include <iostream>
using namespace std;

 

int factorial (int x){
if (x==0)
return 1;
else
return x*factorial(x-1);
}

double calculate_e (double decimal){
double e=0;
int i=0;
double before;
do {
before=e;
e=e+1.0/factorial(i);
i++;
} while (e-before>decimal);
return e;
}

 

int main (){
double decimal;
cout<<“Give me the precision you want your ‘e’ to have”<<endl;
cin>>decimal;
cout<<“The value of your ‘e’ is: “<<calculate_e(decimal)<<endl;

return 0;
}

In this program you ask the user for the precision and it calculates the constant ‘e’. It was a little hard cause I had the idea but I didn’t know how to put it into a program. Teacher Ken helped me a little in this one.


WSQ 11- Go bananas.

--Originally published at Alexa

wsq11

Here is my code: doggy

#include <algorithm>

#include <iostream>

#include <fstream>

#include <string>

using namespace std;

 

int count (string ban){

int bananaCount;

ifstream infile;

int pos;

infile.open(“banana.txt”);

bananaCount=0;

string line;

 

if (infile.is_open())

{

while(getline(infile,line)){

transform(line.begin(), line.end(), line.begin(), ::tolower);

pos = line.find(ban);

while(pos != -1){

cout << “OMG I found a banana at position: ” << pos << endl;

bananaCount++;

pos = line.find(ban,pos+1);

}

}

}

return bananaCount;

infile.close( );

int main(){

string ban=”banana”;

cout<<“Number of bananas: “<<count(ban) <<endl;
return 0;

}

This program was pretty easy cause I already had a program to open files. All I had to do was counting the number of bananas inside a file. The new part about this was that I used a new kind of function inside the algorithm library, it was “transform”. Here I used a lot of mastery topics. http://www.cplusplus.com/reference/algorithm/transform/


Mi cuento.

--Originally published at Alexa

De vez en cuando escribo, cuando tengo tiempo. A continuación les presento mi cuento favorito, lo hice hace tiempo pero me gusta muchísimo.

Amor Universal
En los albores del universo caliginoso, Solari amaba a  Selenum, la luna,  con una intensidad mayor a la que él irradiaba.
La amaba y ella lo amaba de la misma manera. Estaban unidos compartiendo sus energías, él le otorgaba calor y ella enfriaba su temperatura hostigadora. Estaban hechos para estar juntos.
La hermosura de la luna era celestial, sublime, era una belleza pacífica, intrigante. El sol se deleitaba con sus danzas en torno a él, causando eclipses insólitos visibles a gran distancia.
Un día Solari enfermó. La luna era muy fuerte para él y lo estaba enfriando en demasía. El corazón del sol comenzó a tornarse en hielo, el dolor que sentía era horrendo. Solari estaba muriendo y Selenum lo sabía.
Se mantuvieron juntos todo el tiempo que les fue posible, mas luna no sabía qué hacer, estaba desesperada. Ella sabía que lo estaba lastimando y que en un tiempo causaría su muerte, pero él, él no la dejaría ir.
   -¡Oh!, no sabes cuánto te amo, daría mi vida, mi alma y mi felicidad por ti- dijo Selenum.
   -Ni oses pensarlo, si voy a morir quiero que sea a tu lado, es lo único que te pido- replicó Solari.
La luna sonrió entristecida, trató de contener sus lágrimas pero una se escapó y rodó por su mejilla. Sus lágrimas al caer en el espacio se convertían en miles de estrellas, de todos tamaños.
   -No llores por mí, tú eres mi pasión, mi vida, mi amor. Sin ti yo no tendría ninguna razón para vivir. Todas las estrellas en el universo no podrían reemplazar lo que tenemos juntos. Te doy las gracias
Continue reading "Mi cuento."

Project.

--Originally published at Alexa

I tried to think of something not that hard but challenging applying all the knowledges I already have. I said OK, I know how to read information from a file, I’m planning to use toupper on the count bananas wsq and I was like oh! I know! I could make a file with a lot of words on it, read it, choose a random word, input a guess and make the user find out what word we’re talking about. Maybe using categories of animals, fruits, cities in different files. So in less words, I’m going to do a Hangman game!

Week 16-22 October:

Think on the structure begin to write the ideas down.

Week 23-29 October:

Begin the coding. Ask questions.

Week 30-5 October-November:

Keep coding.

Week 6-12 November:

Last week of coding. Finish work.

 


WSQ08 – Yo Soy 196.

--Originally published at Alexa

wsq8

Here is the code FINALLY!!!!!!! for WSQ08.

// Solving Problems with Programming
// Professor Ken Bauer
//
// Alexa Mercado Sánchez
// A01634000
// Jorge Alejandro Flores and Ken Bauer ?

// Standard libraries
#include <string>
#include <iostream>
#include <algorithm>

using namespace std;

// `BigIntegerLibrary.hh’ includes all of the library headers.
#include “BigIntegerLibrary.hh”

/*
* This function receives a BigInteger n and checks if it is a palindrome
* Return true if n is a palindrome, return false otherwise
*/
bool is_palindrome(BigInteger n){
string str1= bigIntegerToString(n);
string str2=str1;
reverse(str2.begin(), str2.end());
return (str2==str1);
}
/*
* This function receives a BigInteger n and returns the value of n plus the inverse of n.
*/
BigInteger apply196(BigInteger n){
string str1= bigIntegerToString(n);
string str2=str1;
reverse(str1.begin(), str1.end());
return n+ stringToBigInteger(str1);// you need to replace this with code that works
}

/*
* Your main program goes below and should use the two functions above
*/
int main() {
int nl=0;
int pal=0;
int l=0;
BigInteger n;
int low, up;

cout << “Give me the value of your lower bound” << endl;
cin >>low;
cout << “Give me the value of your upper bound” << endl;
cin >>up;

for(int i=low; i<=up; i++){
n=i;

if(is_palindrome (n)==true){
pal=pal+1;
}
else {
int count=0;
bool lych= true;
while (count<=30){
n= apply196(n);
if(is_palindrome(n)==true){
nl=nl+1;
lych=false;
break;
}
else{
count=count+1;
}

}
if (lych){
l=l+1;
}
}
}

cout<<“The analyzed numbers goes from “<<low;
cout<<” to “<<up<<endl;
cout<<“There are “<<pal;
cout<<” palindromes”<<endl;
cout<<“There are “<<l;
cout<<” lychrel numbers”<<endl;
cout<<“There are “<<nl;
cout<<” non-lychrel numbers”<<endl;
return 0;
}

 

I tried to do it for like 2 months and after a lot of explanations and time I finally did it. Thanks to everyone for your explanations! Ilysm. Here I used like a lot of mastery topics

Continue reading "WSQ08 – Yo Soy 196."

WSQ 10- Babylonian Method.

--Originally published at Alexa

My code is:

#include <iostream>
using namespace std;

float function (int x, double ok){
int count(10);
double answer, res;

res = x/ok;
ok = (ok + res)/2;

while (count > 0)
{
res = x/ok;
ok = (ok + res)/2;

if (ok <= (ok * 0.01) + ok)
answer = ok;
else
res = x/ok;
ok = (ok + res)/2;

count-=1;
}
return answer;
}

 

int main(){
int x;
double ok;

cout << “Give me the value of your number, please.”<<endl;
cin >> x;
cout << “Give me the number you want to divide by, this is like the guess. “<<endl;
cin >> ok;
cout << “The square root of “<< x << ” is ” << function (x,ok)<<endl;

return 0;
}

wsq10

 

This program calculates the square root of a number by a guess that the user provides. It was kinda of tricky but it worked. Here I used #masterytopic17 cause I considered that a while and a if loop would be the best. I was able to make this code thanks to other classmate’s codes and some youtube tutorials.


WSQ 09- Multipart Data and Files.

--Originally published at Alexa

wsq9.png

My code is:

#include <iostream>

#include <fstream>

#include <string>

using namespace std;

int main()

{

string line;

int charCount, lineCount;

ifstream infile;

 

infile.open(“file.txt”);

charCount=0;

lineCount=0;

 

if (infile.is_open())

{

while( getline (infile, line))

{

lineCount++;

charCount += line.length();

}

}

cout<<“Number of characters: “<<charCount<<endl;

cout<<“Number of lines: “<<lineCount <<endl;

 

infile.close( );

 

return 0;

}

This program analyzes a file and returns the total of characters and the total of lines. I made this code with help from youtube videos and some other blogs.  Here I used #masterytopic21 because I read information from a file.

 


Quiz Week 10

--Originally published at Alexa

#include <iostream>
#include <string>
using namespace std;

int countChars(string userInput, char theChar){

int countChars = 0;

for (int i = 0; i < userInput.size(); i++)
{
if (userInput[i] == theChar)
{
++ countChars;
}
}
return countChars;
}

int main() {
string userInput;
char theChar=’a’;

cout<<“This program will tell you the number of ‘a’ inside your sentence”<<endl;
cout<<“Please type ‘:)’ followed by the sentence you want to analyze.”<<endl;
cin>>userInput;
getline(cin,userInput);

 

cout<<“Your sentence was “<<userInput<<endl;

cout<<“The number of “<<theChar <<” inside “<<userInput<< ” is: “<< countChars (userInput, theChar)<<endl;

return 0;
}quiz10

I’ve been 3 weeks or so trying to figure out how to make the “yosoy169” file and finally making something that runs reliefed me for like 5 seconds. This program was kinda hard too but not impossible. #quizweek10 #banana #kenbauer #masterytopic19 #masterytopic20 #masterytopic21