Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
38 changes: 38 additions & 0 deletions Lab2_1.cpp
Original file line number Diff line number Diff line change
@@ -0,0 +1,38 @@
// ConsoleApplication17.cpp : Defines the entry point for the console application.
//

/*Program: Coin Flip
Date: January 23, 2015
Author: Brianna Melius, with modification by: Zachary Micheal Joseph Anthony Golik and Brandon McCurry
*/

#include "stdafx.h"
#include <iostream>
#include <string>
#include <time.h>
#include <stdio.h>
#include <stdlib.h>
using namespace std;

int main(){
int coin, heads, tails, counter;
heads = 0;
tails = 0;
counter = 0;
srand(time(NULL));
while (counter != 100){
coin = rand() % 2;

if (coin == 0){
heads++;
}
else if (coin == 1){
tails++;
}
counter++;
}
cout << "You flipped heads: " << heads << " times!" << endl;
cout << "You flipped tails: " << tails << " times!" << endl;
getchar();
return 0;
}
48 changes: 48 additions & 0 deletions Lab2_2.cpp
Original file line number Diff line number Diff line change
@@ -0,0 +1,48 @@
// ConsoleApplication18.cpp : Defines the entry point for the console application.
//

#include "stdafx.h"


int _tmain(int argc, _TCHAR* argv[])
{
return 0;
}
#include <iostream>
#include <string>
#include <stdlib.h>
#include <stdio.h>
#include <time.h>
using namespace std;
int main(){
int tries, number, guess;
tries = 1;
guess = 0;
cout << "Welcome to 'Guess My Number'!" << endl;
cout << "I'm thinking of a number between 1 and 100." << endl;
cout << "Try to guess it in as few attempts as possible." << endl;
cout << "Take a guess: ";
cin >> guess;
srand(time(0));
number = rand() % 100 + 1;
while (guess != number){
if (guess > number){
cout << "Lower..." << endl;
}
else if (guess < number){
cout << "Higher..." << endl;
}
cout << "Take a guess: ";
cin >> guess;
tries++;
}
cout << "You guessed it! The number was " << number << endl;
cout << "And it only took you " << tries << " tries!" << endl;
system("pause");
return 0;

}




56 changes: 56 additions & 0 deletions Lab2_3.cpp
Original file line number Diff line number Diff line change
@@ -0,0 +1,56 @@
// ConsoleApplication20.cpp : Defines the entry point for the console application.
//

#include "stdafx.h"
#include <iostream>
#include <string>
#include <time.h>
#include <stdlib.h>
#include <stdio.h>
using namespace std;
int main(){
cout << "*******************************************************" << endl <<
"* WELCOME to *" << endl <<
"* Die - Roller! *" << endl <<
"* *" << endl <<
"* Instructions: *" << endl <<
"* To roll, type the number of dice, then the number *" << endl <<
"* of sides then any modifiers, all separated by *" << endl <<
"* spaces. *" << endl <<
"* *" << endl <<
"* like this : 3 6 - 1 *" << endl <<
"* that would mean : *" << endl <<
"* Roll 3 6 - sided dice, and subtract 1 from each die *" << endl <<
"* *" << endl <<
"* To exit, enter : 1 1 1 *" << endl <<
"* ENJOY! *" << endl <<
"*******************************************************" << endl;
cout << "Your Roll: ";
int rollArray[3] = { 0, 0, 0 }, diceNum = 0, sideNum = 0, modifiers = 0, results = 0, total = 0;
for (int i = 0; i < 3; i++){
cin >> rollArray[i];
}
diceNum = rollArray[0];
sideNum = rollArray[1];
modifiers = rollArray[2];
srand(time(NULL));
while (diceNum != 1, || sideNum != 1, || modifiers != 1){
for (int i = 0; i < diceNum; i++){
total += ((rand() % sideNum + 1;) + modifiers);
}
cout << "Total: " << total;
cout << "Your Roll: ";
int rollArray[3] = { 0, 0, 0 }, diceNum = 0, sideNum = 0, modifiers = 0, results = 0, total = 0;
for (int i = 0; i < 3; i++){
cin >> rollArray[i];
}
diceNum = rollArray[0];
sideNum = rollArray[1];
modifiers = rollArray[2];
getchar();
}
cout << "Thank you, Have a nice day.";
getchar();
getchar();
}