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
41 changes: 41 additions & 0 deletions Lab2_1.cpp
Original file line number Diff line number Diff line change
@@ -0,0 +1,41 @@
// Jacob Steiner=
// 1/23/15
// lab2_1

/*
Pseudocode
flip a coin 100 times and print the user the number of heads
*/

#include "stdafx.h"
#include <iostream>
#include <stdlib.h>
#include <time.h>

using namespace std;

int _tmain(int argc, _TCHAR* argv[])
{
srand(time(NULL));
int heads = 0;
int tails = 0;
int flip;
for (int i = 0; i < 100; i++){

flip = rand() % 2;
if (flip == 0){
tails++;
}
else {
heads++;
}

}

cout << "heads: " << heads << endl;
cout << "tails: " << tails;
getchar();
getchar();
return 0;
}

42 changes: 42 additions & 0 deletions Lab2_2.cpp
Original file line number Diff line number Diff line change
@@ -0,0 +1,42 @@
// jacob steiner
// 1/23/15
// lab2_2

/*Pseudocode
generate a number 1 - 100
have the user guess a number
tell the user if he or she is greater than or less than
if number is right, tell user how many tries it took them
*/

#include "stdafx.h"
#include <iostream>
#include <stdlib.h>
#include <time.h>

using namespace std;

int _tmain(int argc, _TCHAR* argv[])
{
double guess;
double tries = 0;
double number;
cout << "I am thinking of a number 1 - 100, what is it?\n";
srand(time(NULL));
number = rand() % 100 + 1;
cin >> guess;
while (guess != number) {
tries++;
if (guess > number){
cout << "Lower\n";
}
if (guess < number){
cout << "higher\n";
}
cin >> guess;
}
cout << "good, it only took you " << tries << " tries!";
getchar();
return 0;
}

55 changes: 55 additions & 0 deletions Lab2_3.cpp
Original file line number Diff line number Diff line change
@@ -0,0 +1,55 @@
// Jacob Steinier
// 1/23/15
// lab2_3

/*pesudocode
allow user to enter the number of dice, the modifier, and the number of sides of their dice
print out the random dice
if all values are 1
say thanks and exit*/
#include "stdafx.h"
#include <iostream>
#include <string>
#include <stdlib.h>
#include <time.h>

using namespace std;

int _tmain(int argc, _TCHAR* argv[])
{
cout << "* 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;

int dice = 0, side = 0, modifier = 0, stopper = 0;
while (stopper == 0)
{
cout << "\nYour Roll: ";
cin >> dice >> side >> modifier;
if (dice == 1 & side == 1 & modifier == 1){
stopper = 1;
cout << "Thank you, have a nice day!" << endl;
}
else{
for (double i = dice; i > 0; i--){
double v1 = rand() % side + 1;
cout << v1 + modifier << " ";
}
}
}
getchar();
getchar();
return 0;
}