From 36389889c7466ebbab59d79e97e9f755dc1b4c7c Mon Sep 17 00:00:00 2001 From: unknown Date: Thu, 5 Feb 2015 08:31:22 -0600 Subject: [PATCH] new file: Lab2_1.cpp new file: Lab2_2.cpp new file: Lab2_3.cpp.lnk --- Lab2_1.cpp | 35 +++++++++++++++++++++++++++++++++++ Lab2_2.cpp | 42 ++++++++++++++++++++++++++++++++++++++++++ Lab2_3.cpp.lnk | Bin 0 -> 678 bytes 3 files changed, 77 insertions(+) create mode 100644 Lab2_1.cpp create mode 100644 Lab2_2.cpp create mode 100644 Lab2_3.cpp.lnk diff --git a/Lab2_1.cpp b/Lab2_1.cpp new file mode 100644 index 0000000..4e474d3 --- /dev/null +++ b/Lab2_1.cpp @@ -0,0 +1,35 @@ +/**************** +* Lab2_1.cpp * +* By: Zach Golik * +* Date: 1/23/15 * + ****************/ + +#include "stdafx.h" +#include +#include +#include +#include //rand, srand// +#include +using namespace std; + +int main(){ + cout << "I am going to flip a coin 100 times"<< endl << + "Then I will tell you how many heads and how many tails I got." << endl; + int i = 0, heads = 0, tails = 0, flip = 0; //Initializing: heads, tails, i(count), flip(random number)// + srand(time(NULL)); //srand// + while (i != 100){ //WHILE LOOP// + flip = rand() % 2; //Random number// + if (flip == 0){ + heads += 1; + } + else if (flip == 1){ + tails += 1; + } + i += 1; + } + cout << "Heads: " << heads << endl; + cout << "Tails: " << tails << endl; + system("pause"); + return 0; +} + diff --git a/Lab2_2.cpp b/Lab2_2.cpp new file mode 100644 index 0000000..f1ace1f --- /dev/null +++ b/Lab2_2.cpp @@ -0,0 +1,42 @@ +/**************** +* Lab2_2.cpp * +* By: Zach Golik * +* Date: 1/27/15 * + ****************/ + +#include "stdafx.h" +#include +#include +#include +#include +#include +using namespace std; + +int main(){ + int number = 0, i = 0, guess = 0; + srand(time(NULL)); + number = rand() % 100 + 1; + cout << "\tWelcome to 'Guess My Number'!" << endl << + "I'm thinking of a number between 1 and 100." << endl << + "Try to guess it in as few attempts as possible." << endl; + cout << "Take a guess: "; + cin >> guess; + while (guess != number){ + if (guess < number){ + cout << "Higher..." << endl; + i += 1; + } + else if (guess > number) { + cout << "Lower..." << endl; + i += 1; + } + cout << "Take a guess: "; + cin >> guess; + } + cout << "You guessed it! The number was " << number << endl << + "And it only took you " << i << " tries!" << endl << endl << + "Press the enter key to exit."; + getchar(); + getchar(); + return 0; +} \ No newline at end of file diff --git a/Lab2_3.cpp.lnk b/Lab2_3.cpp.lnk new file mode 100644 index 0000000000000000000000000000000000000000..1e720cbc5957bad752c6510c35436f46d80173f3 GIT binary patch literal 678 zcmeZaU|?VrVFHp23S~<+@+W!i|m)XbRG?z`Y+qyT^mCQgB*jiTdAK$^kXDkiizwWv78(-lO=I2RPe1057^U=)MwE)}31dO&yMBC+{22CEyT z7@QfbfF^}96f>kU6amQ?V7R%$`7uCw%uv$+I+c@wVFAcLhQR^BkGdk<_V`#h@BSk^ zS#3t{IgnRCAOVPh{#y_M;s8NrszrHbp1H1}F@&$wRk-