diff --git a/1-hello-world/art/bjarne.gif b/1-hello-world/art/bjarne.gif new file mode 100644 index 0000000..7c91ea1 Binary files /dev/null and b/1-hello-world/art/bjarne.gif differ diff --git a/1-hello-world/art/bjarne2.gif b/1-hello-world/art/bjarne2.gif new file mode 100644 index 0000000..82c67a3 Binary files /dev/null and b/1-hello-world/art/bjarne2.gif differ diff --git a/1-hello-world/art/codecademy.jpg b/1-hello-world/art/codecademy.jpg new file mode 100644 index 0000000..da6df63 Binary files /dev/null and b/1-hello-world/art/codecademy.jpg differ diff --git a/1-hello-world/art/compiler.png b/1-hello-world/art/compiler.png new file mode 100644 index 0000000..766025f Binary files /dev/null and b/1-hello-world/art/compiler.png differ diff --git a/1-hello-world/art/emoji-mailbox.png b/1-hello-world/art/emoji-mailbox.png new file mode 100644 index 0000000..32d5b83 Binary files /dev/null and b/1-hello-world/art/emoji-mailbox.png differ diff --git a/1-hello-world/art/file-name.png b/1-hello-world/art/file-name.png new file mode 100644 index 0000000..618d4fb Binary files /dev/null and b/1-hello-world/art/file-name.png differ diff --git a/1-hello-world/art/files1.png b/1-hello-world/art/files1.png new file mode 100644 index 0000000..974cc3c Binary files /dev/null and b/1-hello-world/art/files1.png differ diff --git a/1-hello-world/art/files2.png b/1-hello-world/art/files2.png new file mode 100644 index 0000000..2a44d45 Binary files /dev/null and b/1-hello-world/art/files2.png differ diff --git a/1-hello-world/art/folder-icon.png b/1-hello-world/art/folder-icon.png new file mode 100644 index 0000000..24b881d Binary files /dev/null and b/1-hello-world/art/folder-icon.png differ diff --git a/1-hello-world/art/folder-icon.svg b/1-hello-world/art/folder-icon.svg new file mode 100644 index 0000000..5004f16 --- /dev/null +++ b/1-hello-world/art/folder-icon.svg @@ -0,0 +1,6 @@ + + + + + + diff --git a/1-hello-world/art/process-quiz.png b/1-hello-world/art/process-quiz.png new file mode 100644 index 0000000..a346a83 Binary files /dev/null and b/1-hello-world/art/process-quiz.png differ diff --git a/1-hello-world/art/process.gif b/1-hello-world/art/process.gif new file mode 100644 index 0000000..0eb4ea2 Binary files /dev/null and b/1-hello-world/art/process.gif differ diff --git a/1-hello-world/art/process.png b/1-hello-world/art/process.png new file mode 100644 index 0000000..3b2b2c6 Binary files /dev/null and b/1-hello-world/art/process.png differ diff --git a/1-hello-world/art/process.svg b/1-hello-world/art/process.svg new file mode 100644 index 0000000..0d1c5a1 --- /dev/null +++ b/1-hello-world/art/process.svg @@ -0,0 +1,202 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/1-hello-world/art/program-structure.png b/1-hello-world/art/program-structure.png new file mode 100644 index 0000000..a4f4b79 Binary files /dev/null and b/1-hello-world/art/program-structure.png differ diff --git a/1-hello-world/art/terminal.png b/1-hello-world/art/terminal.png new file mode 100644 index 0000000..54537f4 Binary files /dev/null and b/1-hello-world/art/terminal.png differ diff --git a/1-hello-world/art/xkcd-compiling.png b/1-hello-world/art/xkcd-compiling.png new file mode 100644 index 0000000..1577dcf Binary files /dev/null and b/1-hello-world/art/xkcd-compiling.png differ diff --git a/1-hello-world/block-letters/block-letters-hint.png b/1-hello-world/block-letters/block-letters-hint.png new file mode 100644 index 0000000..83b8f4e Binary files /dev/null and b/1-hello-world/block-letters/block-letters-hint.png differ diff --git a/1-hello-world/block-letters/block-letters.png b/1-hello-world/block-letters/block-letters.png new file mode 100644 index 0000000..ede4f21 Binary files /dev/null and b/1-hello-world/block-letters/block-letters.png differ diff --git a/1-hello-world/block-letters/challenge-anytext.cpp b/1-hello-world/block-letters/challenge-anytext.cpp new file mode 100644 index 0000000..12d7d82 --- /dev/null +++ b/1-hello-world/block-letters/challenge-anytext.cpp @@ -0,0 +1,394 @@ +// Fun fact: I like blockchain and genetics + +// Objective: respond the challenge with a code +// that lets you print any text in block letters. +// Original repo: https://github.com/fbitti/codecademy-cpp-challenge + +// Instructions: Change this line with your text: +// string input = "Yay C++"; // here is where you input the text to be printed out +// $ g++ challenge-anytext.cpp +// $ ./a.out +// Y Y A Y Y CCC +// Y Y A A Y Y C C +// Y A A Y C + + +// Y AAAAA Y C +++++ +++++ +// Y A A Y C + + +// Y A A Y C C +// Y A A Y CCC + +#include +#include + +using namespace std; // to avoid repeating std:: in front of every string declaration + +class BlockLetter { // this object will make a loop easier to implement and keep the main() code smaller + public: + string letter; + string line1Pattern; + string line2Pattern; + string line3Pattern; + string line4Pattern; + string line5Pattern; + string line6Pattern; + string line7Pattern; + + string line(int num) { // it returns the corresponding line, so we don't introduce breaks before the end of the line + string result; + switch(num) { + case 1: + result = line1Pattern; + break; + case 2: + result = line2Pattern; + break; + case 3: + result = line3Pattern; + break; + case 4: + result = line4Pattern; + break; + case 5: + result = line5Pattern; + break; + case 6: + result = line6Pattern; + break; + case 7: + result = line7Pattern; + } + return result; + } +}; + +BlockLetter convertChar2BlockLetter(char letter); // just declaring the function, the definition comes after main() + +int main() { + + string input = "Yay C++"; // here is where you input the text to be printed out + + BlockLetter block[input.size()]; + + for (int c=0; c < input.size(); c++) { // let's convert the text into an array of block letters + block[c] = convertChar2BlockLetter(input[c]); + } + + for (int l=1; l <= 7; l++) { + for (int c = 0; c < input.size(); c++) { + std::cout << block[c].line(l) + " "; + } + std::cout << "\n"; + } + +} + +BlockLetter convertChar2BlockLetter(char letter) { // this function defines all characters in the alphabet + BlockLetter result; + switch(letter) { + case 'a': // both lowercase and uppercase letters are accepted :) + case 'A': + result.letter = 'A'; + result.line1Pattern = " A "; + result.line2Pattern = " A A "; + result.line3Pattern = "A A"; + result.line4Pattern = "AAAAA"; + result.line5Pattern = "A A"; + result.line6Pattern = "A A"; + result.line7Pattern = "A A"; + return result; + case 'b': + case 'B': + result.letter = 'B'; + result.line1Pattern = "BBBB "; + result.line2Pattern = "B B"; + result.line3Pattern = "B B"; + result.line4Pattern = "BBBB "; + result.line5Pattern = "B B"; + result.line6Pattern = "B B"; + result.line7Pattern = "BBBB "; + return result; + case 'c': + case 'C': + result.letter = 'C'; + result.line1Pattern = " CCC "; + result.line2Pattern = "C C"; + result.line3Pattern = "C "; + result.line4Pattern = "C "; + result.line5Pattern = "C "; + result.line6Pattern = "C C"; + result.line7Pattern = " CCC "; + return result; + case 'd': + case 'D': + result.letter = 'D'; + result.line1Pattern = "DDDD "; + result.line2Pattern = "D D"; + result.line3Pattern = "D D"; + result.line4Pattern = "D D"; + result.line5Pattern = "D D"; + result.line6Pattern = "D D"; + result.line7Pattern = "DDDD"; + return result; + case 'e': + case 'E': + result.letter = 'E'; + result.line1Pattern = "EEEEE"; + result.line2Pattern = "E "; + result.line3Pattern = "E "; + result.line4Pattern = "EEE "; + result.line5Pattern = "E "; + result.line6Pattern = "E "; + result.line7Pattern = "EEEEE"; + return result; + case 'f': + case 'F': + result.letter = 'F'; + result.line1Pattern = "FFFFF"; + result.line2Pattern = "F "; + result.line3Pattern = "F "; + result.line4Pattern = "FFF "; + result.line5Pattern = "F "; + result.line6Pattern = "F "; + result.line7Pattern = "F "; + return result; + case 'g': + case 'G': + result.letter = 'G'; + result.line1Pattern = " GGG "; + result.line2Pattern = "G G"; + result.line3Pattern = "G "; + result.line4Pattern = "G GGG"; + result.line5Pattern = "G G"; + result.line6Pattern = "G G"; + result.line7Pattern = " GGG "; + return result; + case 'h': + case 'H': + result.letter = 'H'; + result.line1Pattern = "H H"; + result.line2Pattern = "H H"; + result.line3Pattern = "H H"; + result.line4Pattern = "HHHHH"; + result.line5Pattern = "H H"; + result.line6Pattern = "H H"; + result.line7Pattern = "H H"; + return result; + case 'i': + case 'I': + result.letter = 'I'; + result.line1Pattern = "IIIII"; + result.line2Pattern = " I "; + result.line3Pattern = " I "; + result.line4Pattern = " I "; + result.line5Pattern = " I "; + result.line6Pattern = " I "; + result.line7Pattern = "IIIII"; + return result; + case 'j': + case 'J': + result.letter = 'J'; + result.line1Pattern = "JJJJJ"; + result.line2Pattern = " J "; + result.line3Pattern = " J "; + result.line4Pattern = " J "; + result.line5Pattern = "J J "; + result.line6Pattern = "J J "; + result.line7Pattern = " JJ "; + return result; + case 'k': + case 'K': + result.letter = 'K'; + result.line1Pattern = "K K"; + result.line2Pattern = "K K "; + result.line3Pattern = "K K "; + result.line4Pattern = "KK "; + result.line5Pattern = "K K "; + result.line6Pattern = "K K "; + result.line7Pattern = "K K"; + return result; + case 'l': + case 'L': + result.letter = 'L'; + result.line1Pattern = "L "; + result.line2Pattern = "L "; + result.line3Pattern = "L "; + result.line4Pattern = "L "; + result.line5Pattern = "L "; + result.line6Pattern = "L "; + result.line7Pattern = "LLLLL"; + return result; + case 'm': + case 'M': + result.letter = 'M'; + result.line1Pattern = "M M"; + result.line2Pattern = "MM MM"; + result.line3Pattern = "MM MM"; + result.line4Pattern = "M M M"; + result.line5Pattern = "M M"; + result.line6Pattern = "M M"; + result.line7Pattern = "M M"; + return result; + case 'n': + case 'N': + result.letter = 'N'; + result.line1Pattern = "N N"; + result.line2Pattern = "NN N"; + result.line3Pattern = "N N N"; + result.line4Pattern = "N NN"; + result.line5Pattern = "N N"; + result.line6Pattern = "N N"; + result.line7Pattern = "N N"; + return result; + case 'o': + case 'O': + result.letter = 'O'; + result.line1Pattern = " OOO "; + result.line2Pattern = "O O"; + result.line3Pattern = "O O"; + result.line4Pattern = "O O"; + result.line5Pattern = "O O"; + result.line6Pattern = "O O"; + result.line7Pattern = " OOO "; + return result; + case 'p': + case 'P': + result.letter = 'P'; + result.line1Pattern = " PPP "; + result.line2Pattern = "P P"; + result.line3Pattern = "P P"; + result.line4Pattern = "PPPP "; + result.line5Pattern = "P "; + result.line6Pattern = "P "; + result.line7Pattern = "P "; + return result; + case 'q': + case 'Q': + result.letter = 'Q'; + result.line1Pattern = " QQQ "; + result.line2Pattern = "Q Q"; + result.line3Pattern = "Q Q"; + result.line4Pattern = "Q Q"; + result.line5Pattern = "Q Q"; + result.line6Pattern = "Q Q "; + result.line7Pattern = " QQ Q"; + return result; + case 'r': + case 'R': + result.letter = 'R'; + result.line1Pattern = "RRRR "; + result.line2Pattern = "R R"; + result.line3Pattern = "R R"; + result.line4Pattern = "RRRR "; + result.line5Pattern = "R R "; + result.line6Pattern = "R R "; + result.line7Pattern = "R R"; + return result; + case 's': + case 'S': + result.letter = 'S'; + result.line1Pattern = " SSS "; + result.line2Pattern = "S S"; + result.line3Pattern = "S "; + result.line4Pattern = " SSS "; + result.line5Pattern = " S"; + result.line6Pattern = "S S"; + result.line7Pattern = " SSS "; + return result; + case 't': + case 'T': + result.letter = 'T'; + result.line1Pattern = "TTTTT"; + result.line2Pattern = " T "; + result.line3Pattern = " T "; + result.line4Pattern = " T "; + result.line5Pattern = " T "; + result.line6Pattern = " T "; + result.line7Pattern = " T "; + return result; + case 'u': + case 'U': + result.letter = 'U'; + result.line1Pattern = "U U"; + result.line2Pattern = "U U"; + result.line3Pattern = "U U"; + result.line4Pattern = "U U"; + result.line5Pattern = "U U"; + result.line6Pattern = "U U"; + result.line7Pattern = " UUU "; + return result; + case 'v': + case 'V': + result.letter = 'V'; + result.line1Pattern = "V V"; + result.line2Pattern = "V V"; + result.line3Pattern = "V V"; + result.line4Pattern = "V V"; + result.line5Pattern = "V V"; + result.line6Pattern = " V V "; + result.line7Pattern = " V "; + return result; + case 'w': + case 'W': + result.letter = 'W'; + result.line1Pattern = "W W"; + result.line2Pattern = "W W"; + result.line3Pattern = "W W"; + result.line4Pattern = "W W W"; + result.line5Pattern = "WW WW"; + result.line6Pattern = "WW WW"; + result.line7Pattern = "W W"; + return result; + case 'x': + case 'X': + result.letter = 'X'; + result.line1Pattern = "X X"; + result.line2Pattern = "X X"; + result.line3Pattern = " X X "; + result.line4Pattern = " X "; + result.line5Pattern = " X X "; + result.line6Pattern = "X X"; + result.line7Pattern = "X X"; + return result; + case 'y': + case 'Y': + result.letter = 'Y'; + result.line1Pattern = "Y Y"; + result.line2Pattern = " Y Y "; + result.line3Pattern = " Y "; + result.line4Pattern = " Y "; + result.line5Pattern = " Y "; + result.line6Pattern = " Y "; + result.line7Pattern = " Y "; + return result; + case 'z': + case 'Z': + result.letter = 'Z'; + result.line1Pattern = "ZZZZZ"; + result.line2Pattern = " Z"; + result.line3Pattern = " Z "; + result.line4Pattern = " Z "; + result.line5Pattern = " Z "; + result.line6Pattern = "Z "; + result.line7Pattern = "ZZZZZ"; + return result; + case '+': + result.letter = '+'; + result.line1Pattern = " "; + result.line2Pattern = " "; + result.line3Pattern = " + "; + result.line4Pattern = "+++++"; + result.line5Pattern = " + "; + result.line6Pattern = " "; + result.line7Pattern = " "; + return result; + default: // returns a blank block if the char is not on the list. + result.letter = ' '; + result.line1Pattern = " "; + result.line2Pattern = " "; + result.line3Pattern = " "; + result.line4Pattern = " "; + result.line5Pattern = " "; + result.line6Pattern = " "; + result.line7Pattern = " "; + return result; + } +} diff --git a/1-hello-world/block-letters/codecademy.cpp b/1-hello-world/block-letters/codecademy.cpp new file mode 100644 index 0000000..10cbeb7 --- /dev/null +++ b/1-hello-world/block-letters/codecademy.cpp @@ -0,0 +1,26 @@ +// Fun Fact: Artichokes are my favorite vegetable. +// Twitter: @JoannaMathes + +#include + +int main() { + + std::cout << " __________________ \n"; + std::cout << " | |______________| | \n"; + std::cout << " | | | | \n"; + std::cout << " | | | | \n"; + std::cout << " | | | | \n"; + std::cout << " | | XXXXX | | \n"; + std::cout << " | | XX X | | \n"; + std::cout << " | | X | | \n"; + std::cout << " | | X | | \n"; + std::cout << " | | X | | \n"; + std::cout << " | | XX X | | \n"; + std::cout << " | | XXXXX | | \n"; + std::cout << " | | | | ========== \n"; + std::cout << " | |--------------| | | | \n"; + std::cout << " |__________________| ========== \n"; + + return 0; + +} diff --git a/1-hello-world/block-letters/initials.cpp b/1-hello-world/block-letters/initials.cpp new file mode 100644 index 0000000..38baf0a --- /dev/null +++ b/1-hello-world/block-letters/initials.cpp @@ -0,0 +1,19 @@ +// Sonny Li +// Fun Fact: I played guitar in a band called Attica. + +#include + +int main() +{ + + std::cout << " SSS L \n"; + std::cout << " S S L \n"; + std::cout << " S L \n"; + std::cout << " SSS L \n"; + std::cout << " S L \n"; + std::cout << " S S L \n"; + std::cout << " SSS LLLLL \n"; + + return 0; + +} diff --git a/1-hello-world/block-letters/snowman.cpp b/1-hello-world/block-letters/snowman.cpp new file mode 100644 index 0000000..380c1c3 --- /dev/null +++ b/1-hello-world/block-letters/snowman.cpp @@ -0,0 +1,28 @@ +// Fun Fact: I drink a looot of water. + +#include + +int main() { + + std::cout << " * * \n"; + std::cout << "* * \n"; + std::cout << " * * * \n"; + std::cout << " * * \n"; + std::cout << " * \n"; + std::cout << "* * * \n"; + std::cout << " * * * \n"; + std::cout << " HHHHHHH * \n"; + std::cout << " * HHHHHHH \n"; + std::cout << " * HHHHHHHHHHH * * \n"; + std::cout << " * @ @ * \n"; + std::cout << " * ^ * \n"; + std::cout << " * * * * \n"; + std::cout << " SSS * * S \n"; + std::cout << " * SSSSSSSS * \n"; + std::cout << " * O SS * \n"; + std::cout << " * O S * \n"; + std::cout << " * O * \n"; + std::cout << " * * \n"; + std::cout << " * * * \n"; + +} \ No newline at end of file diff --git a/1-hello-world/hello.cpp b/1-hello-world/hello.cpp new file mode 100644 index 0000000..7b1b07d --- /dev/null +++ b/1-hello-world/hello.cpp @@ -0,0 +1,7 @@ +#include + +int main() { + + std::cout << "Hello World!\n"; + +} diff --git a/1-hello-world/letter.cpp b/1-hello-world/letter.cpp new file mode 100644 index 0000000..91d4f9c --- /dev/null +++ b/1-hello-world/letter.cpp @@ -0,0 +1,13 @@ +#include + +int main() { + + std::cout << "Dear Self, \n"; + std::cout << " \n"; + std::cout << "I will build a VR app.\n"; + std::cout << " \n"; + std::cout << " - Sonny\n"; + + return 0; + +} \ No newline at end of file diff --git a/1-hello-world/pattern.cpp b/1-hello-world/pattern.cpp new file mode 100644 index 0000000..0432950 --- /dev/null +++ b/1-hello-world/pattern.cpp @@ -0,0 +1,11 @@ +#include + +int main() +{ + + std::cout << " 1\n"; + std::cout << " 2 3\n"; + std::cout << " 4 5 6\n"; + std::cout << "7 8 9 10\n"; + +} diff --git a/1-hello-world/spell.cpp b/1-hello-world/spell.cpp new file mode 100644 index 0000000..8a66820 --- /dev/null +++ b/1-hello-world/spell.cpp @@ -0,0 +1,11 @@ +// Harry Potter spell + +#include + +int main() { + + std::cout << "Expecto Patronum\n"; + + return 0; + +} \ No newline at end of file diff --git a/2-variables/bmi.cpp b/2-variables/bmi.cpp new file mode 100644 index 0000000..b7a6aa2 --- /dev/null +++ b/2-variables/bmi.cpp @@ -0,0 +1,19 @@ +#include + +int main() { + + double height, weight, bmi; + + std::cout << "Type in your height (m): "; + std::cin >> height; + + std::cout << "Type in your weight (kg): "; + std::cin >> weight; + + bmi = weight / (height * height); + + std::cout << "Your BMI is " << bmi << "\n"; + + return 0; + +} \ No newline at end of file diff --git a/2-variables/data-types-other.png b/2-variables/data-types-other.png new file mode 100644 index 0000000..a9e5fdb Binary files /dev/null and b/2-variables/data-types-other.png differ diff --git a/2-variables/data-types.gif b/2-variables/data-types.gif new file mode 100644 index 0000000..1fa514d Binary files /dev/null and b/2-variables/data-types.gif differ diff --git a/2-variables/declare-intialize.png b/2-variables/declare-intialize.png new file mode 100644 index 0000000..6df4a86 Binary files /dev/null and b/2-variables/declare-intialize.png differ diff --git a/2-variables/dog-years/dog-white.gif b/2-variables/dog-years/dog-white.gif new file mode 100644 index 0000000..8b6ba85 Binary files /dev/null and b/2-variables/dog-years/dog-white.gif differ diff --git a/2-variables/dog-years/dog.gif b/2-variables/dog-years/dog.gif new file mode 100644 index 0000000..14fb231 Binary files /dev/null and b/2-variables/dog-years/dog.gif differ diff --git a/2-variables/dog-years/dog_years1.cpp b/2-variables/dog-years/dog_years1.cpp new file mode 100644 index 0000000..7324681 --- /dev/null +++ b/2-variables/dog-years/dog_years1.cpp @@ -0,0 +1,21 @@ +// Learn C++ +// Dog Years + +#include + +int main() +{ + + int dog_age = 3; + + int early_years, later_years, human_years; + + early_years = 21; + + later_years = (dog_age - 2) * 4; + + human_years = early_years + later_years; + + std::cout << "My name is Sparkles! Ruff Ruff, I am " << human_years << " years old in human years.\n"; + +} diff --git a/2-variables/dog-years/dog_years2.cpp b/2-variables/dog-years/dog_years2.cpp new file mode 100644 index 0000000..d820284 --- /dev/null +++ b/2-variables/dog-years/dog_years2.cpp @@ -0,0 +1,29 @@ +// Learn C++ +// Dog Years + +#include + +int main() { + + std::string dog_name; + int dog_age; + + int early_years, later_years, human_years; + + std::cout << "Enter your dog's name: "; + std::cin >> dog_name; + + std::cout << "Enter your dog's age: "; + std::cin >> dog_age; + + early_years = 21; + + later_years = (dog_age - 2) * 4; + + human_years = early_years + later_years; + + std::cout << "My name is " << dog_name << "! Ruff Ruff, I am " << human_years << " years old in human years.\n"; + + return 0; + +} \ No newline at end of file diff --git a/2-variables/piggy-bank/Oct-31-2018 19-08-11.gif b/2-variables/piggy-bank/Oct-31-2018 19-08-11.gif new file mode 100644 index 0000000..c12b5da Binary files /dev/null and b/2-variables/piggy-bank/Oct-31-2018 19-08-11.gif differ diff --git a/2-variables/piggy-bank/currency.cpp b/2-variables/piggy-bank/currency.cpp new file mode 100644 index 0000000..9383f5a --- /dev/null +++ b/2-variables/piggy-bank/currency.cpp @@ -0,0 +1,25 @@ +#include + +int main() +{ + + double p; + double q; + double c; + + double dollars; + + std::cout << "🇲🇽 Enter number of Pesos: "; + std::cin >> p; + + std::cout << "🇬🇹 Enter number of Guatemalan Quetzals: "; + std::cin >> q; + + std::cout << "🇸🇻 Enter number of Salvadoran Colons: "; + std::cin >> c; + + dollars = 0.049 * p + 0.1305 * q + 0.1144 * c; + + std::cout << "Total USD = $" << dollars << "\n"; + +} diff --git a/2-variables/piggy-bank/currency2.cpp b/2-variables/piggy-bank/currency2.cpp new file mode 100644 index 0000000..13271d7 --- /dev/null +++ b/2-variables/piggy-bank/currency2.cpp @@ -0,0 +1,33 @@ +#include +#include + +// exchange rates sourced from https://www.fiscal.treasury.gov/reports-statements/treasury-reporting-rates-exchange/current.html +int main() { + double p; + // peso rate = 19.6540 + double ep = 19.6540; + + double q; + // quetzal rate = 7.7150 + double eq = 7.7150; + + double c; + // colóns rate = 603.5000 + double ec = 603.5000; + + double dollars; + std::cout << "Enter number of Mexican Pesos:"; + std::cin >> p; + std::cout << "Enter number of quetzals:"; + std::cin >> q; + std::cout << "Enter number of colóns:"; + std::cin >> c; + + + // foriegn ammount / rate = usd + + dollars = (p/ep)+(q/eq)+(c/ec); + + std::cout << "US Dollars = $" << dollars << "\n"; + +} diff --git a/2-variables/piggy-bank/flag-for-el-salvador.png b/2-variables/piggy-bank/flag-for-el-salvador.png new file mode 100644 index 0000000..6333003 Binary files /dev/null and b/2-variables/piggy-bank/flag-for-el-salvador.png differ diff --git a/2-variables/piggy-bank/flag-for-guatemala.png b/2-variables/piggy-bank/flag-for-guatemala.png new file mode 100644 index 0000000..62db221 Binary files /dev/null and b/2-variables/piggy-bank/flag-for-guatemala.png differ diff --git a/2-variables/piggy-bank/flag-for-mexico.png b/2-variables/piggy-bank/flag-for-mexico.png new file mode 100644 index 0000000..7eceadd Binary files /dev/null and b/2-variables/piggy-bank/flag-for-mexico.png differ diff --git a/2-variables/piggy-bank/piggy-bank.gif b/2-variables/piggy-bank/piggy-bank.gif new file mode 100644 index 0000000..66903c4 Binary files /dev/null and b/2-variables/piggy-bank/piggy-bank.gif differ diff --git a/2-variables/piggy-bank/piggy-bank2.gif b/2-variables/piggy-bank/piggy-bank2.gif new file mode 100644 index 0000000..0b040c7 Binary files /dev/null and b/2-variables/piggy-bank/piggy-bank2.gif differ diff --git a/2-variables/piggy-bank/piggybank.gif b/2-variables/piggy-bank/piggybank.gif new file mode 100644 index 0000000..2a24817 Binary files /dev/null and b/2-variables/piggy-bank/piggybank.gif differ diff --git a/2-variables/quadratic-formula/graph.gif b/2-variables/quadratic-formula/graph.gif new file mode 100644 index 0000000..2f88580 Binary files /dev/null and b/2-variables/quadratic-formula/graph.gif differ diff --git a/2-variables/quadratic-formula/quadratic-formula.png b/2-variables/quadratic-formula/quadratic-formula.png new file mode 100644 index 0000000..3420723 Binary files /dev/null and b/2-variables/quadratic-formula/quadratic-formula.png differ diff --git a/2-variables/quadratic-formula/quadratic.cpp b/2-variables/quadratic-formula/quadratic.cpp new file mode 100644 index 0000000..56c4c39 --- /dev/null +++ b/2-variables/quadratic-formula/quadratic.cpp @@ -0,0 +1,26 @@ +#include +#include + +int main() { + + double a, b, c; + double root1, root2; + + std::cout << "Enter a: "; + std::cin >> a; + + std::cout << "Enter b: "; + std::cin >> b; + + std::cout << "Enter c: "; + std::cin >> c; + + root1 = (-b + sqrt(b*b - 4*a*c)) / (2*a); + root2 = (-b - sqrt(b*b - 4*a*c)) / (2*a); + + std::cout << "Root 1 is " << root1 << "\n"; + std::cout << "Root 2 is " << root2 << "\n"; + + return 0; + +} diff --git a/2-variables/temperature1.cpp b/2-variables/temperature1.cpp new file mode 100644 index 0000000..fbb80df --- /dev/null +++ b/2-variables/temperature1.cpp @@ -0,0 +1,14 @@ +#include + +int main() { + + double tempf = 83.0; + double tempc; + + tempc = (tempf - 32) / 1.8; + + std::cout << "The temp is " << tempc << " degrees Celsius.\n"; + + return 0; + +} \ No newline at end of file diff --git a/2-variables/temperature2.cpp b/2-variables/temperature2.cpp new file mode 100644 index 0000000..8aac07d --- /dev/null +++ b/2-variables/temperature2.cpp @@ -0,0 +1,19 @@ +#include + +int main() { + + double tempf; + double tempc; + + // Ask the user + std::cout << "Enter the temperature in Fahrenheit: "; + + std::cin >> tempf; + + tempc = (tempf - 32) / 1.8; + + std::cout << "The temp is " << tempc << " degrees Celsius.\n"; + + return 0; + +} \ No newline at end of file diff --git a/3-conditionals-and-logic/coinflip.cpp b/3-conditionals-and-logic/coinflip.cpp new file mode 100644 index 0000000..7412708 --- /dev/null +++ b/3-conditionals-and-logic/coinflip.cpp @@ -0,0 +1,22 @@ +#include +#include +#include + +int main() { + + srand (time(NULL)); + int coin = rand() % 2; + + if (coin == 0) { + + std::cout << "Heads\n"; + + } else { + + std::cout << "Tails\n"; + + } + + return 0; + +} \ No newline at end of file diff --git a/3-conditionals-and-logic/coinflip.gif b/3-conditionals-and-logic/coinflip.gif new file mode 100644 index 0000000..135c790 Binary files /dev/null and b/3-conditionals-and-logic/coinflip.gif differ diff --git a/3-conditionals-and-logic/coinflip1.gif b/3-conditionals-and-logic/coinflip1.gif new file mode 100644 index 0000000..fc67a29 Binary files /dev/null and b/3-conditionals-and-logic/coinflip1.gif differ diff --git a/3-conditionals-and-logic/grade.cpp b/3-conditionals-and-logic/grade.cpp new file mode 100644 index 0000000..95e93b2 --- /dev/null +++ b/3-conditionals-and-logic/grade.cpp @@ -0,0 +1,19 @@ +#include + +int main() { + + int grade = 59; + + if (grade >= 60) { + + std::cout << "Pass\n"; + + } else { + + std::cout << "Fail\n"; + + } + + return 0; + +} \ No newline at end of file diff --git a/3-conditionals-and-logic/harry-potter-sorting-hat/harrypotter.gif b/3-conditionals-and-logic/harry-potter-sorting-hat/harrypotter.gif new file mode 100644 index 0000000..b4b638a Binary files /dev/null and b/3-conditionals-and-logic/harry-potter-sorting-hat/harrypotter.gif differ diff --git a/3-conditionals-and-logic/harry-potter-sorting-hat/points.gif b/3-conditionals-and-logic/harry-potter-sorting-hat/points.gif new file mode 100644 index 0000000..44dace8 Binary files /dev/null and b/3-conditionals-and-logic/harry-potter-sorting-hat/points.gif differ diff --git a/3-conditionals-and-logic/harry-potter-sorting-hat/sortinghat.cpp b/3-conditionals-and-logic/harry-potter-sorting-hat/sortinghat.cpp new file mode 100644 index 0000000..25599a0 --- /dev/null +++ b/3-conditionals-and-logic/harry-potter-sorting-hat/sortinghat.cpp @@ -0,0 +1,153 @@ +#include + +int main() { + + int gryffindor = 0; + int hufflepuff = 0; + int ravenclaw = 0; + int slytherin = 0; + + int answer1, answer2, answer3, answer4; + + std::cout << "===============\n"; + std::cout << "The Sorting Hat\n"; + std::cout << "===============\n\n"; + + // ~~~~~~~~~~ Question 1 ~~~~~~~~~~ + + std::cout << "Q1) When I'm dead, I want people to remember me as:\n\n"; + + std::cout << " 1) The Good\n"; + std::cout << " 2) The Great\n"; + std::cout << " 3) The Wise\n"; + std::cout << " 4) The Bold\n\n"; + + std::cout << "Enter your answer (1-4): "; + std::cin >> answer1; + + if (answer1 == 1) + hufflepuff++; + else if (answer1 == 2) + slytherin++; + else if (answer1 == 3) + ravenclaw++; + else if (answer1 == 4) + gryffindor++; + + // ~~~~~~~~~~ Question 2 ~~~~~~~~~~ + + std::cout << "\nQ2) Dawn or Dusk?\n\n"; + + std::cout << " 1) Dawn\n"; + std::cout << " 2) Dusk\n\n"; + + std::cout << "Enter your answer (1-2): "; + std::cin >> answer2; + + if (answer2 == 1) + { + + gryffindor++; + ravenclaw++; + + } + else if (answer2 == 2) + { + + hufflepuff++; + slytherin++; + + } + else + { + + std::cout << "Invalid input\n"; + + } + + // ~~~~~~~~~~ Question 3 ~~~~~~~~~~ + + std::cout << "\nQ3) Which kind of instrument most pleases your ear?\n\n"; + + std::cout << " 1) The violin\n"; + std::cout << " 2) The trumpet\n"; + std::cout << " 3) The piano\n"; + std::cout << " 4) The drum\n\n"; + + std::cout << "Enter your answer (1-4): "; + std::cin >> answer3; + + if (answer3 == 1) + slytherin++; + else if (answer3 == 2) + hufflepuff++; + else if (answer3 == 3) + ravenclaw++; + else if (answer3 == 4) + gryffindor++; + + // ~~~~~~~~~~ Question 4 ~~~~~~~~~~ + + std::cout << "\nQ4) Which road tempts you the most?\n\n"; + + std::cout << " 1) The wide, sunny grassy lane\n"; + std::cout << " 2) The narrow, dark, lantern-lit alley\n"; + std::cout << " 3) The twisting, leaf-strewn path through woods\n"; + std::cout << " 4) The cobbled street lined (ancient buildings)\n\n"; + + std::cout << "Enter your answer (1-4): "; + std::cin >> answer4; + + if (answer4 == 1) + hufflepuff++; + else if (answer4 == 2) + slytherin++; + else if (answer4 == 3) + gryffindor++; + else if (answer4 == 4) + ravenclaw++; + + // ========== Sorting ========== + + std::cout << "\nCongrats on being sorted into... "; + + int max = 0; + std::string house; + + if (gryffindor > max) + { + + max = gryffindor; + house = "Gryffindor"; + + } + + if (hufflepuff > max) + { + + max = hufflepuff; + house = "Hufflepuff"; + + } + + if (ravenclaw > max) + { + + max = ravenclaw; + house = "Ravenclaw"; + + } + + if (slytherin > max) + { + + max = slytherin; + house = "Slytherin"; + + } + + std::cout << house << "!\n"; + + return 0; + +} diff --git a/3-conditionals-and-logic/magic-8-ball/magic8.cpp b/3-conditionals-and-logic/magic-8-ball/magic8.cpp new file mode 100644 index 0000000..a05f045 --- /dev/null +++ b/3-conditionals-and-logic/magic-8-ball/magic8.cpp @@ -0,0 +1,115 @@ +#include +#include + +int main() { + + std::cout << "MAGIC 🎱 SAYS: \n\n"; + + srand(time(NULL)); + + int choice = rand() % 20; + + if (choice == 0) { + + std::cout << "It is certain.\n"; + + } + else if (choice == 1) { + + std::cout << "It is decidedly so.\n"; + + } + else if (choice == 2) { + + std::cout << "Without a doubt.\n"; + + } + else if (choice == 3) { + + std::cout << "Yes - definitely.\n"; + + } + else if (choice == 4) { + + std::cout << "You may rely on it.\n"; + + } + else if (choice == 5) { + + std::cout << "As I see it, yes.\n"; + + } + else if (choice == 6) { + + std::cout << "Most likely.\n"; + + } + else if (choice == 7) { + + std::cout << "Outlook good.\n"; + + } + else if (choice == 8) { + + std::cout << "Yes.\n"; + + } + else if (choice == 9) { + + std::cout << "Signs point to yes.\n"; + + } + else if (choice == 10) { + + std::cout << "Reply hazy, try again.\n"; + + } + else if (choice == 11) { + + std::cout << "Ask again later.\n"; + + } + else if (choice == 12) { + + std::cout << "Better not tell you now.\n"; + + } + else if (choice == 13) { + + std::cout << "Cannot predict now.\n"; + + } + else if (choice == 14) { + + std::cout << "Concentrate and ask again.\n"; + + } + else if (choice == 15) { + + std::cout << "Don't count on it.\n"; + + } + else if (choice == 16) { + + std::cout << "My reply is no.\n"; + + } + else if (choice == 17) { + + std::cout << "My sources say no.\n"; + + } + else if (choice == 18) { + + std::cout << "Outlook not so good.\n"; + + } + else { + + std::cout << "Very doubtful.\n"; + + } + + return 0; + +} diff --git a/3-conditionals-and-logic/magic-8-ball/magic8ball.gif b/3-conditionals-and-logic/magic-8-ball/magic8ball.gif new file mode 100644 index 0000000..e9ae71f Binary files /dev/null and b/3-conditionals-and-logic/magic-8-ball/magic8ball.gif differ diff --git a/3-conditionals-and-logic/magic-8-ball/switch_magic-8-ball b/3-conditionals-and-logic/magic-8-ball/switch_magic-8-ball new file mode 100644 index 0000000..83cc45a --- /dev/null +++ b/3-conditionals-and-logic/magic-8-ball/switch_magic-8-ball @@ -0,0 +1,78 @@ +#include +#include + +using namespace std; +int main(){ + + cout<<"MAGIC 8-BALL:\n"; + + srand(time(NULL)); + int answer = rand()%20; + + //std::cout< + +int main() { + + float rides; // number of subway or local bus rides + float express; // number of express bus rides + + char living; // living or visiting + + std::cout << "====================================================\n"; + std::cout << "Welcome to the MetroCard Calculator! - New York City\n"; + std::cout << "====================================================\n"; + std::cout << "\n"; + + std::cout << "The fare for a subway or local bus ride: $2.75\n"); + std::cout << "The fare for an express bus ride: $6.50\n"); + std::cout << "\n"; + + std::cout << "Do you live here or are you visiting? (Input L/V):"); + std::cin >> living; + + if (living == 'L' || living == 'l') { + + float monthlycost; // monthly cost using single fare rides + + std::cout << "\n"; + std::cout << "How many times do you use the subway/bus a week?:"; + scanf("%f", &rides); + + printf("\n"); + printf("How many times do you use the express bus a week?:"); + scanf("%f", &express); + + monthlycost = (4 * rides * 2.75) + (4 * express * 6.50); + + printf("\n"); + printf("============\n"); + printf("MONTHLY COST\n"); + printf("============\n\n"); + + printf(" - Using Single Fare Rides $%0.2f\n", monthlycost); + printf(" - Using 7-Day Unlimited Card (x4) $128.00\n"); + printf(" - Using 30-Day Unlimited Card $121.00\n"); + + printf("==============================================\n\n"); + + if (monthlycost > 121) { + + printf("It would be better to use the 30-Day Unlimited.\n"); + printf("You would save $%0.2f per month.\n", monthlycost - 121); + + } + else { + + printf("It would be better to use Single Fare rides.\n"); + printf("You would save $%0.2f per month.\n", 121 - monthlycost); + + } + + } + else if (living == 'V' || living == 'v') { + + float days; // number of days + int weeks; // number of weeks (rounded up) + + float tripcost; // trip cost using single fare rides + float unlimited; // trip cost using 7-day unlimited + + printf("\n"); + printf("How many days total are you staying in New York?:"); + scanf("%f", &days); + + printf("\n"); + printf("How many times do you use the subway/bus per day?:"); + scanf("%f", &rides); + + printf("\n"); + printf("How many times do you use the express bus per day?:"); + scanf("%f", &express); + + tripcost = (days * rides * 2.75) + (days * express * 6.50); + + if (days <= 7) + { + weeks = 1; + } + else if (days <= 14) + { + weeks = 2; + } + else if (days <= 21) + { + weeks = 3; + } + else if (days <= 28) + { + weeks = 4; + } + else if (days <= 35) + { + weeks = 5; + } + else if (days <= 42) + { + weeks = 6; + } + else if (days <= 49) + { + weeks = 7; + } + + unlimited = weeks * 32.00; + + printf("\n"); + printf("=========\n"); + printf("TRIP COST\n"); + printf("=========\n\n"); + + printf(" - Using Single Fare Rides: $%0.2f\n", tripcost); + printf(" - Using 7-Day Unlimited Card: (x%d) $%0.2f\n", weeks, unlimited); + printf(" - Using 30-Day Unlimited Card: $121.00\n"); + + printf("================================================\n\n"); + + if (tripcost < 121 && tripcost < unlimited) { + + printf("It would be better to use Single Fare rides.\n"); + printf("You would save $%0.2f vs. using 30-Day Unlimited.\n", 121 - tripcost); + printf("You would save $%0.2f vs. using 7-Day Unlimited.\n", unlimited - tripcost); + + } + else if (unlimited < tripcost && unlimited < 121) { + + printf("It would be better to use the 7-Day Unlimited.\n"); + printf("You would save $%0.2f vs. using 30-Day Unlimited.\n", 121 - unlimited); + printf("You would save $%0.2f vs. using Single Fare Rides.\n", tripcost - unlimited); + + } + else if (tripcost > 121 && unlimited > 121) { + + printf("It would be better to use the 30-Day Unlimited.\n"); + printf("You would save $%f vs. using 7-Day Unlimited.\n", unlimited - 121); + printf("You would save $%f vs. using Single Fare Rides.\n", tripcost - 121); + + } + + } + else { + + printf("\n"); + printf("=============\n"); + printf("Invalid Entry\n"); + printf("=============\n"); + + } + + return 0; + +} diff --git a/3-conditionals-and-logic/pH.cpp b/3-conditionals-and-logic/pH.cpp new file mode 100644 index 0000000..92af652 --- /dev/null +++ b/3-conditionals-and-logic/pH.cpp @@ -0,0 +1,23 @@ +#include + +int main() { + + double ph = 4.6; + + if (ph > 7) { + + std::cout << "Basic\n"; + + } else if (ph < 7) { + + std::cout << "Acidic\n"; + + } else { + + std::cout << "Neutral\n"; + + } + + return 0; + +} \ No newline at end of file diff --git a/3-conditionals-and-logic/pokedex.cpp b/3-conditionals-and-logic/pokedex.cpp new file mode 100644 index 0000000..3803d19 --- /dev/null +++ b/3-conditionals-and-logic/pokedex.cpp @@ -0,0 +1,44 @@ +#include + +int main() { + + int number = 9; + + switch(number) { + + case 1 : + std::cout << "Bulbusaur\n"; + break; + case 2 : + std::cout << "Ivysaur\n"; + break; + case 3 : + std::cout << "Venusaur\n"; + break; + case 4 : + std::cout << "Charmander\n"; + break; + case 5 : + std::cout << "Charmeleon\n"; + break; + case 6 : + std::cout << "Charizard\n"; + break; + case 7 : + std::cout << "Squirtle\n"; + break; + case 8 : + std::cout << "Wartortle\n"; + break; + case 9 : + std::cout << "Blastoise\n"; + break; + default : + std::cout << "Not starter\n"; + break; + + } + + return 0; + +} \ No newline at end of file diff --git a/3-conditionals-and-logic/rock-paper-scissors-lizard-spock/RPSLS.gif b/3-conditionals-and-logic/rock-paper-scissors-lizard-spock/RPSLS.gif new file mode 100644 index 0000000..2443e18 Binary files /dev/null and b/3-conditionals-and-logic/rock-paper-scissors-lizard-spock/RPSLS.gif differ diff --git a/3-conditionals-and-logic/rock-paper-scissors-lizard-spock/rock_paper_scissors.cpp b/3-conditionals-and-logic/rock-paper-scissors-lizard-spock/rock_paper_scissors.cpp new file mode 100644 index 0000000..0ba4723 --- /dev/null +++ b/3-conditionals-and-logic/rock-paper-scissors-lizard-spock/rock_paper_scissors.cpp @@ -0,0 +1,98 @@ +#include +#include + +int main() { + + srand(time(NULL)); + + int computer = rand() % 3 + 1; + + int user; + + std::cout << "====================\n"; + std::cout << "rock paper scissors!\n"; + std::cout << "====================\n"; + + std::cout << "1) ✊\n"; + std::cout << "2) ✋\n"; + std::cout << "3) ✌️\n"; + + std::cout << "shoot! "; + + std::cin >> user; + + if (user == 1) + std::cout << "you choose: ✊\n"; + else if (user == 2) + std::cout << "you choose: ✋\n"; + else + std::cout << "you choose: ✌️\n"; + + if (computer == 1) + std::cout << "cpu choose: ✊\n"; + else if (computer == 2) + std::cout << "cpu choose: ✋\n"; + else + std::cout << "cpu choose: ✌️\n"; + + + if (user == computer) { + + std::cout << "it's a tie!\n"; + + } + + // user rock + + else if (user == 1) { + + if (computer == 2) { + + std::cout << "you lost! booooo!\n"; + + } + if (computer == 3) { + + std::cout << "you won! woohoo!\n"; + + } + + } + + // user paper + + else if (user == 2) { + + if (computer == 1) { + + std::cout << "you won! woohoo!\n"; + + } + if (computer == 3) { + + std::cout << "you lost! boo!\n"; + + } + + } + + // user scissors + + else if (user == 3) { + + if (computer == 1) { + + std::cout << "you won! woohoo!\n"; + + } + if (computer == 2) { + + std::cout << "you lost! booooo!\n"; + + } + + } + + return 0; + +} diff --git a/3-conditionals-and-logic/rock-paper-scissors-lizard-spock/rock_paper_scissors_lizard_spock.cpp b/3-conditionals-and-logic/rock-paper-scissors-lizard-spock/rock_paper_scissors_lizard_spock.cpp new file mode 100644 index 0000000..3939990 --- /dev/null +++ b/3-conditionals-and-logic/rock-paper-scissors-lizard-spock/rock_paper_scissors_lizard_spock.cpp @@ -0,0 +1,147 @@ +/* As Sheldon explains, "Scissors cuts paper, paper covers rock, +rock crushes lizard, lizard poisons Spock, Spock smashes scissors, +scissors decapitates lizard, lizard eats paper, paper disproves Spock, +Spock vaporizes rock, and as it always has, rock crushes scissors." +*/ + +#include +#include +#include + +int main() { + + // Get computer selection + srand (time(NULL)); + int computer = rand() % 5 + 1; + + int user; + + std::cout << "1) Rock\n"; + std::cout << "2) Paper\n"; + std::cout << "3) Scissors\n"; + std::cout << "4) Lizard\n"; + std::cout << "5) Spock\n"; + std::cout << "Choose your weapon: "; + std::cin >> user; + + switch (user) { + case 1: // Human chooses Rock + switch (computer) { + case 1: // Computer chooses Rock + std::cout << "You tie! You both chose Rock!\n"; + break; + case 2: // Computer chooses Paper + std::cout << "Computer wins! Paper covers Rock!\n"; + break; + case 3: // Computer chooses Scissors + std::cout << "You win! Rock crushes Scissors!\n"; + break; + case 4: // Computer chooses Lizard + std::cout << "You win! Rock crushes Lizard!\n"; + break; + case 5: // Computer chooses Spock + std::cout << "Computer wins! Spock vaporizes Rock!\n"; + break; + default: // Something went wrong with rand + std::cout << "Computer tried to cheat!?!\n"; + break; + } + break; + case 2: // Human chooses Paper + switch (computer) { + case 1: // Computer chooses Rock + std::cout << "You win! Paper covers Rock!\n"; + break; + case 2: // Computer chooses Paper + std::cout << "You tie! You both chose Paper!\n"; + break; + case 3: // Computer chooses Scissors + std::cout << "Computer wins! Scissors cuts Paper!\n"; + break; + case 4: // Computer chooses Lizard + std::cout << "Computer wins! Lizard eats Paper!\n"; + break; + case 5: // Computer chooses Spock + std::cout << "You win! Paper disproves Spock!\n"; + break; + default: // Something went wrong with rand + std::cout << "Computer tried to cheat!?!\n"; + break; + } + break; + case 3: // Human chooses Scissors + switch (computer) { + case 1: // Computer chooses Rock + std::cout << "Computer wins! Rock crushes Scissors!\n"; + break; + case 2: // Computer chooses Paper + std::cout << "You win! Scissors cuts Paper!\n"; + break; + case 3: // Computer chooses Scissors + std::cout << "You tie! You both chose Scissors!\n"; + break; + case 4: // Computer chooses Lizard + std::cout << "You win! Scissors decapitates Lizard!\n"; + break; + case 5: // Computer chooses Spock + std::cout << "Computer wins! Spock smashes Scissors!\n"; + break; + default: // Something went wrong with rand + std::cout << "Computer tried to cheat!?!\n"; + break; + } + break; + case 4: // Human chooses Lizard + switch (computer) { + case 1: // Computer chooses Rock + std::cout << "Computer wins! Rock crushes Lizard!\n"; + break; + case 2: // Computer chooses Paper + std::cout << "You win! Lizard eats Paper!\n"; + break; + case 3: // Computer chooses Scissors + std::cout << "Computer wins! Scissors decapitates Lizard!\n"; + break; + case 4: // Computer chooses Lizard + std::cout << "You tie! You both chose Lizard!\n"; + break; + case 5: // Computer chooses Spock + std::cout << "You win! Lizard poisons Spock!\n"; + break; + default: // Something went wrong with rand + std::cout << "Computer tried to cheat!?!\n"; + break; + } + break; + case 5: // Human chooses Vulcan + switch (computer) { + case 1: // Computer chooses Rock + std::cout << "You win! Spock vaporizes Rock!\n"; + break; + case 2: // Computer chooses Paper + std::cout << "Computer wins! Paper disproves Spock!\n"; + break; + case 3: // Computer chooses Scissors + std::cout << "You win! Spock smashes Scissors!\n"; + break; + case 4: // Computer chooses Lizard + std::cout << "Computer wins! Lizard poisons Spock!\n"; + break; + case 5: // Computer chooses Spock + std::cout << "You tie! You both chose Spock!\n"; + break; + default: // Something went wrong with rand + std::cout << "Computer tried to cheat!?!\n"; + break; + } + break; + default: // Human chose outside 1-5 range + std::cout << "Did you try to cheat?!\n"; + break; + } + + std::cout << "Thank you for playing. Put me in a loop to play more!\n"; + + return 0; + +} diff --git a/3-conditionals-and-logic/space.cpp b/3-conditionals-and-logic/space.cpp new file mode 100644 index 0000000..c1b1029 --- /dev/null +++ b/3-conditionals-and-logic/space.cpp @@ -0,0 +1,48 @@ +#include + +int main() { + + double weight; + int x; + + std::cout << "Please enter your current earth weight: "; + std::cin >> weight; + + std::cout << "\nI have information for the following planets:\n\n"; + std::cout << " 1. Venus 2. Mars 3. Jupiter\n"; + std::cout << " 4. Saturn 5. Uranus 6. Neptune\n\n"; + + std::cout << "Which planet are you visiting? "; + std::cin >> x; + + if (x == 1) { + + weight = weight * 0.78; + + } else if (x == 2) { + + weight = weight * 0.39; + + } else if (x == 3) { + + weight = weight * 2.65; + + } else if (x == 4) { + + weight = weight * 1.17; + + } else if (x == 5) { + + weight = weight * 1.05; + + } else if (x == 6) { + + weight = weight * 1.23; + + } + + std::cout << "\nYour weight: " << weight << "\n"; + + return 0; + +} \ No newline at end of file diff --git a/3-conditionals-and-logic/streetsign.gif b/3-conditionals-and-logic/streetsign.gif new file mode 100644 index 0000000..e0eaa77 Binary files /dev/null and b/3-conditionals-and-logic/streetsign.gif differ diff --git a/4-loops/99bottles.cpp b/4-loops/99bottles.cpp new file mode 100644 index 0000000..31ab834 --- /dev/null +++ b/4-loops/99bottles.cpp @@ -0,0 +1,22 @@ +#include + +int main() { + + // Write a for loop here: + + for (int i = 99; i > 0; i--) { + + std::cout << i << " bottles of pop on the wall.\n"; + std::cout << "Take one down and pass it around.\n"; + std::cout << i - 1 << " bottles of pop on the wall.\n\n"; + + } + + std::cout << "No more bottles of pop on the wall.\n"; + std::cout << "No more bottles of pop.\n"; + std::cout << "Go to the store and buy some more,\n"; + std::cout << "99 bottles of pop on the wall.\n"; + + return 0; + +} \ No newline at end of file diff --git a/4-loops/art/bug.gif b/4-loops/art/bug.gif new file mode 100644 index 0000000..21bc8f6 Binary files /dev/null and b/4-loops/art/bug.gif differ diff --git a/4-loops/art/bug.jpg b/4-loops/art/bug.jpg new file mode 100644 index 0000000..76495d1 Binary files /dev/null and b/4-loops/art/bug.jpg differ diff --git a/4-loops/art/circle.png b/4-loops/art/circle.png new file mode 100644 index 0000000..67f76d3 Binary files /dev/null and b/4-loops/art/circle.png differ diff --git a/4-loops/art/troublemaker.png b/4-loops/art/troublemaker.png new file mode 100644 index 0000000..f69bc0b Binary files /dev/null and b/4-loops/art/troublemaker.png differ diff --git a/4-loops/enter_pin.cpp b/4-loops/enter_pin.cpp new file mode 100644 index 0000000..898d03e --- /dev/null +++ b/4-loops/enter_pin.cpp @@ -0,0 +1,26 @@ +#include + +int main() { + + int pin = 0; + int tries = 0; + + std::cout << "BANK OF CODECADEMY\n"; + + std::cout << "Enter your PIN: "; + std::cin >> pin; + + while (pin != 1234) { + + std::cout << "Wrong PIN. Try again: "; + std::cin >> pin; + tries++; + + } + + std::cout << "PIN accepted!\n"; + std::cout << "You now have access.\n"; + + return 0; + +} \ No newline at end of file diff --git a/4-loops/fizzbuzz/fizzbuzz.cpp b/4-loops/fizzbuzz/fizzbuzz.cpp new file mode 100644 index 0000000..12a53e3 --- /dev/null +++ b/4-loops/fizzbuzz/fizzbuzz.cpp @@ -0,0 +1,29 @@ +#include + +int main() { + + for (int i = 1; i <= 100; i++) { + + if (i % 15 == 0) { + + std::cout << "FizzBuzz\n"; + + } else if (i % 5 == 0) { + + std::cout << "Buzz\n"; + + } else if (i % 3 == 0) { + + std::cout << "Fizz\n"; + + } else { + + std::cout << i << "\n"; + + } + + } + + return 0; + +} diff --git a/4-loops/fizzbuzz/fizzbuzz.gif b/4-loops/fizzbuzz/fizzbuzz.gif new file mode 100644 index 0000000..f1eb213 Binary files /dev/null and b/4-loops/fizzbuzz/fizzbuzz.gif differ diff --git a/4-loops/fizzbuzz/fizzbuzz3.cpp b/4-loops/fizzbuzz/fizzbuzz3.cpp new file mode 100644 index 0000000..e31b814 --- /dev/null +++ b/4-loops/fizzbuzz/fizzbuzz3.cpp @@ -0,0 +1,27 @@ +#include + +int main(){ + + bool fizzBuzzed = false; + + for (int i = 1; i <= 100; i++){ + + if (i % 3 == 0){ + std::cout << "Fizz"; + fizzBuzzed = true; + } + + if (i % 5 == 0){ + std::cout << "Buzz"; + fizzBuzzed = true; + } + + if (!fizzBuzzed){ + std::cout << i; + } + + std::cout << "\n"; + fizzBuzzed = false; + } + +} diff --git a/4-loops/guess.cpp b/4-loops/guess.cpp new file mode 100644 index 0000000..596d8ac --- /dev/null +++ b/4-loops/guess.cpp @@ -0,0 +1,26 @@ +#include + +int main() { + + int answer = 8; + + int guess; + + std::cout << "I have a number 1-10.\n"; + std::cout << "Please guess it: "; + std::cin >> guess; + + // Write a while loop here: + + while (guess != 8) { + + std::cout << "Wrong guess, try again: "; + std::cin >> guess; + + } + + std::cout << "You got it!\n"; + + return 0; + +} \ No newline at end of file diff --git a/4-loops/square.cpp b/4-loops/square.cpp new file mode 100644 index 0000000..1db21fc --- /dev/null +++ b/4-loops/square.cpp @@ -0,0 +1,22 @@ +#include + +int main() { + + int i = 0; + int square = 0; + + // Write a while loop here: + + while (i < 10) { + + square = i * i; + + std::cout << i << " " << square << "\n"; + + i++; + + } + + return 0; + +} \ No newline at end of file diff --git a/4-loops/troublemaker.cpp b/4-loops/troublemaker.cpp new file mode 100644 index 0000000..248be7c --- /dev/null +++ b/4-loops/troublemaker.cpp @@ -0,0 +1,13 @@ +#include + +int main() { + + for (int i = 0; i < 10; i++) { + + std::cout << "I will not throw paper airplanes in class.\n"; + + } + + return 0; + +} \ No newline at end of file diff --git a/5-vectors/art/11235.gif b/5-vectors/art/11235.gif new file mode 100644 index 0000000..582a23e Binary files /dev/null and b/5-vectors/art/11235.gif differ diff --git a/5-vectors/whale.cpp b/5-vectors/whale.cpp new file mode 100644 index 0000000..fbd14e2 --- /dev/null +++ b/5-vectors/whale.cpp @@ -0,0 +1,47 @@ +#include +#include +#include + +int main() { + + std::string input = "Turpentine and turtles."; + + std::vector vowels; + + vowels.push_back('a'); + vowels.push_back('e'); + vowels.push_back('i'); + vowels.push_back('o'); + vowels.push_back('u'); + + std::vector whale_talk; + + for (int i = 0; i < input.size(); i++) { + + for (int j = 0; j < vowels.size(); j++) { + + if (input[i] == vowels[j]) { + + whale_talk.push_back(input[i]); + + if (input[i] == 'e' || input [i] == 'u') { + + whale_talk.push_back(input[i]); + + } + + } + + } + + } + + for (int k = 0; k < whale_talk.size(); k++) { + + std::cout << whale_talk[k]; + + } + + std::cout << "\n"; + +} \ No newline at end of file diff --git a/8-pointers/pointers.cpp b/8-pointers/pointers.cpp new file mode 100644 index 0000000..5b34571 --- /dev/null +++ b/8-pointers/pointers.cpp @@ -0,0 +1,12 @@ +#include + +int main() { + + int a = 54; + + std::cout << "a = " << a << "\n"; + std::cout << "address of a is at &a = " << &a << "\n"; + + return 0; + +} diff --git a/8-pointers/pointers.png b/8-pointers/pointers.png new file mode 100644 index 0000000..cb15c67 Binary files /dev/null and b/8-pointers/pointers.png differ diff --git a/README.md b/README.md new file mode 100644 index 0000000..3a3ba68 --- /dev/null +++ b/README.md @@ -0,0 +1,129 @@ +# Learn C++ | Codecademy + + + +**Curriulum Developer:** Sonny Li (sonny@codecademy.com) + +**Curriulum Developer:** Mariel Frank (mariel@codecademy.com) + +**Artwork:** Jared Langel + +## Course Link ## + +https://www.codecademy.com/learn/learn-c-plus-plus + +### Textbook ### + +[Programming Principles and Practice Using C++](https://www.amazon.com/Programming-Principles-Practice-Using-C/dp/0321543726#customerReviews) (Bjarne Stroustrup) + +### Discord ### + +[https://discord.gg/N95DFrT](https://discord.gg/N95DFrT) + + +## 1. Hello World ## + +``` +$ g++ hello.cpp -o hello +$ ./hello +``` + +- [x] [`hello.cpp`](1-hello-world/hello.cpp) +- [x] [`pattern.cpp`](1-hello-world/pattern.cpp) +- [x] [`letter.cpp`](1-hello-world/letter.cpp) +- [x] [`spell.cpp`](1-hello-world/spell.cpp) + +**Block Letters:** + +- [x] [`initials.cpp`](1-hello-world/block-letters/initials.cpp) +- [x] [`snowman.cpp`](1-hello-world/block-letters/snowman.cpp) +- [x] [`codecademy.cpp`](1-hello-world/block-letters/codecademy.cpp) + +## 2. Variables ## + +- [x] [`temperature1.cpp`](2-variables/temperature1.cpp) +- [x] [`temperature2.cpp`](2-variables/temperature2.cpp) +- [x] [`bmi.cpp`](2-variables/bmi.cpp) + +**Dog Years:** + +- [x] [`dog_years1.cpp`](2-variables/dog-years/dog_years1.cpp) +- [x] [`dog_years2.cpp`](2-variables/dog-years/dog_years2.cpp) + +**Quadratic Formula:** + +- [x] [`quadratic.cpp`](2-variables/quadratic-formula/quadratic.cpp) + +**Piggy Bank:** + +- [x] [`currency.cpp`](2-variables/piggy-bank/currency.cpp) + +## 3. Conditionals & Logic ## + +- [x] [`coinflip.cpp`](3-conditionals-and-logic/coinflip.cpp) +- [x] [`grade.cpp`](3-conditionals-and-logic/grade.cpp) +- [x] [`pH.cpp`](3-conditionals-and-logic/pH.cpp) +- [x] [`pokedex.cpp`](3-conditionals-and-logic/pokedex.cpp) +- [x] [`space.cpp`](3-conditionals-and-logic/space.cpp) +- [ ] `leapyear.cpp` + +**Magic 8-Ball** + +- [x] [`magic8.cpp`](3-conditionals-and-logic/magic-8-ball/magic8.cpp) + +**Harry Potter Sorting Hat** + +- [x] [`sortinghat.cpp`](3-conditionals-and-logic/harry-potter-sorting-hat/sortinghat.cpp) + +**Rock Paper Scissors Lizard Spock** + +- [x] [`rock_paper_scissors.cpp`](3-conditionals-and-logic/rock-paper-scissors-lizard-spock/rock_paper_scissors.cpp) +- [x] [`rock_paper_scissors_lizard_spock.cpp`](3-conditionals-and-logic/rock-paper-scissors-lizard-spock/rock_paper_scissors_lizard_spock.cpp) + +## 4. Loops ## + +- [x] [`enter_pin.cpp`](4-loops/enter_pin.cpp) +- [x] [`guess.cpp`](4-loops/guess.cpp) +- [x] [`square.cpp`](4-loops/square.cpp) +- [x] [`troublemaker.cpp`](4-loops/troublemaker.cpp) +- [x] [`99bottles.cpp`](4-loops/99bottles.cpp) + +**Fizz Buzz** + +- [x] [`fizzbuzz.cpp`](4-loops/fizzbuzz/fizzbuzz.cpp) + +## 5. Vectors ## + +- [ ] `tokyo.cpp` +- [ ] `whale.cpp` +- [ ] `bleep.cpp` +- [ ] `ufo.cpp` + +## 6. Functions ## + +## 7. OOP ## + +## 8. Pointers ## + +### Terminal Game Challenge 2019 ### + +* Coming soon! + +### Codecademy C++ Style Guide ### + +* Coming soon! + +### Codecademy C++ Cheatsheets ### + +* Coming soon! + +### Hall of Fame ### + +* You? + +
+ +Black Jack + +## License +Codecademy © [Songqiao Li](https://www.sonnyli.co) diff --git a/Screen Shot 2019-02-01 at 1.28.26 PM.png b/Screen Shot 2019-02-01 at 1.28.26 PM.png new file mode 100644 index 0000000..ed31d6f Binary files /dev/null and b/Screen Shot 2019-02-01 at 1.28.26 PM.png differ diff --git a/Screen Shot 2019-02-01 at 1.28.36 PM.png b/Screen Shot 2019-02-01 at 1.28.36 PM.png new file mode 100644 index 0000000..57f7ce0 Binary files /dev/null and b/Screen Shot 2019-02-01 at 1.28.36 PM.png differ diff --git a/bleep2.cpp b/bleep2.cpp new file mode 100644 index 0000000..76f7baa --- /dev/null +++ b/bleep2.cpp @@ -0,0 +1,53 @@ +#include +#include + +int main() { + + std::string entry = "I like tofu and tofu likes me."; + + std::vector words; + + std::string word = ""; + + std::string censored = "tofu"; + + for (int i = 0; i < entry.size(); i++) { + + if (entry[i] != ' ') { + + word += entry[i]; + + } else { + + words.push_back(word); + + } + + } + + for (int i = 0; i < words.size(); i++) { + + std::cout << words[i] << " "; + + } + + + // for (int i = 0; i < words.size(); i++) { + + // if (words[i] == "tofu"){ + + // std::cout << "BLEEP"; + + // } + // else { + + // std::cout << words[i] << " "; + + // } + // } + + std::cout << "\n"; + + return 0; + +} \ No newline at end of file diff --git a/cheatsheets/cheatsheet1.pdf b/cheatsheets/cheatsheet1.pdf new file mode 100644 index 0000000..37b0ab4 Binary files /dev/null and b/cheatsheets/cheatsheet1.pdf differ diff --git a/cheatsheets/cheatsheet2.pdf b/cheatsheets/cheatsheet2.pdf new file mode 100644 index 0000000..967519f Binary files /dev/null and b/cheatsheets/cheatsheet2.pdf differ diff --git a/logo.png b/logo.png new file mode 100644 index 0000000..e699a59 Binary files /dev/null and b/logo.png differ diff --git a/other/Screen Shot 2019-02-05 at 6.09.25 PM.png b/other/Screen Shot 2019-02-05 at 6.09.25 PM.png new file mode 100644 index 0000000..08218c6 Binary files /dev/null and b/other/Screen Shot 2019-02-05 at 6.09.25 PM.png differ diff --git a/other/Screen Shot 2019-02-13 at 12.34.27 PM.png b/other/Screen Shot 2019-02-13 at 12.34.27 PM.png new file mode 100644 index 0000000..df24ab8 Binary files /dev/null and b/other/Screen Shot 2019-02-13 at 12.34.27 PM.png differ diff --git a/other/Screen Shot 2019-02-13 at 12.34.32 PM.png b/other/Screen Shot 2019-02-13 at 12.34.32 PM.png new file mode 100644 index 0000000..0d64b22 Binary files /dev/null and b/other/Screen Shot 2019-02-13 at 12.34.32 PM.png differ diff --git a/other/Screen Shot 2019-02-13 at 12.34.37 PM.png b/other/Screen Shot 2019-02-13 at 12.34.37 PM.png new file mode 100644 index 0000000..52ec67b Binary files /dev/null and b/other/Screen Shot 2019-02-13 at 12.34.37 PM.png differ diff --git a/other/Screen Shot 2019-02-13 at 12.40.08 PM.png b/other/Screen Shot 2019-02-13 at 12.40.08 PM.png new file mode 100644 index 0000000..a1ef3c9 Binary files /dev/null and b/other/Screen Shot 2019-02-13 at 12.40.08 PM.png differ diff --git a/other/Screen Shot 2019-02-13 at 12.40.13 PM.png b/other/Screen Shot 2019-02-13 at 12.40.13 PM.png new file mode 100644 index 0000000..96edf1d Binary files /dev/null and b/other/Screen Shot 2019-02-13 at 12.40.13 PM.png differ diff --git a/other/Screen Shot 2019-02-14 at 1.49.31 PM.png b/other/Screen Shot 2019-02-14 at 1.49.31 PM.png new file mode 100644 index 0000000..5cee452 Binary files /dev/null and b/other/Screen Shot 2019-02-14 at 1.49.31 PM.png differ diff --git a/other/location.png b/other/location.png new file mode 100644 index 0000000..2b3f7f0 Binary files /dev/null and b/other/location.png differ