1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167
|
#include <iostream>
#include <cmath>
#include <iomanip>
using namespace std;
//Global Constants
//Function Prototypes
//Execution
int main(int argc, char** argv) {
//Declare Variables
unsigned int short choose;
//Prompt user for number of problem to execute
<<endl;
cout<<"5 hours is the most I am willing to admit I spent on that problem"<<endl;
cout<<endl;
cout<<endl;
do { //DO LOOP BEGIN
cout<<"Choose from the following list"<<endl;
cout<<"1. Savitch 8th Edition Chapter 3 Problem 1-RPS"<<endl;
cout<<"2. Savitch 8th Edition Chapter 3 Problem 2-Interest"<<endl;
cout<<"3. Savitch 8th Edition Chapter 3 Problem 3-CUSP"<<endl;
cout<<"4. Savitch 8th Edition Chapter 3 Problem 4-Element"<<endl;
cout<<"5. Savitch 8th Edition Chapter 3 Problem 5-CallMe!"<<endl;
cout<<"6. Savitch 8th Edition Chapter 3 Problem 7-Roman v1.1"<<endl;
cout<<"7. Savitch 8th Edition Chapter 3 Problem 8-Blackjack"<<endl;
cout<<"8. Savitch 8th Edition Chapter 3 Problem 9-Capitalism"<<endl;
cout<<"9. Savitch 8th Edition Chapter 3 Problem 10crud(incomplete)"<<endl;
cout<<"10. Savitch 8th Edition Chapter 3 Problem 14-Optimus"<<endl;
cout<<"11. Savitch 8th Edition Chapter 3 Problem 15-Sphere"<<endl;
cout<<"12. Savitch 8th Edition Chapter 3 Problem 16-Temperature"<<endl;
cout<<"13. Savitch 8th Edition Chapter 3 Problem 17-Fat v2.0"<<endl;
cout<<"14. Savitch 8th Edition Chapter 3 Problem 18-Keypad"<<endl;
cout<<"15. Truth Table"<<endl;
cout<<"16. Exit Program - All"<<endl;
cin>>choose;
//Catch invalid input
if (!(choose<=16)) {
cout<<"Not an option!"<<endl;
}
//Utilize switch to implement the menu
switch(choose) {
case 1:{
///////////////////////////////PROBLEM 1 Savitch Chp3Prb1////////////////////////
cout<<"Welcome to Option 1.";
cout<<endl;
//START CODE//////////////////////////////
//Variables
char player1, player2, exit;
//Prompt
do {
cout<<"Lets play rock paper scissors"<<endl;
cout<<"Player 1, press R for Rock, P, for paper, and S for scissors"<<endl;
//Player 1 input
cin>>player1;
cout<<"Player 2, press R for Rock, P, for paper, and S for scissors"<<endl;
//Player 2 input
cin>>player2;
//Player 1 deciphered first, then player 2. Game ends
//Rock
if ((player1=='r')||(player1=='R')) {
if ((player2=='r')||(player2=='R')) {
cout<<"You tied!"<<endl;
break;
}
if ((player2=='s')||(player2=='S')) {
cout<<"Player 1 wins with Rock smashing Scissors!"<<endl;
break;
}
if ((player2=='p')||(player2=='P')) {
cout<<"Player 2 wins with Paper smothering Rock!"<<endl;
break;
}
else {
cout<<"Player2 made an invalid entry!!!"<<endl;
break;
}
}
//Scissors
else if ((player1=='s')||(player1=='S')) {
if ((player2=='s')||(player2=='S')) {
cout<<"You tied!"<<endl;
break;
}
if ((player2=='p')||(player2=='P')) {
cout<<"Player 1 wins with Scissors cutting Paper!"<<endl;
break;
}
if ((player2=='r')||(player2=='R')) {
cout<<"Player 2 wins with Rock smashing scissors!"<<endl;
break;
}
else {
cout<<"Player2 made an invalid entry!!!"<<endl;
break;
}
}
//Paper
else if ((player1=='p')||(player1=='P')) {
if ((player2=='p')||(player2=='P')) {
cout<<"You tied!"<<endl;
break;
}
if ((player2=='r')||(player2=='R')) {
cout<<"Player 1 wins with Paper smothering Rock!"<<endl;
break;
}
if ((player2=='s')||(player2=='S')) {
cout<<"Player 2 wins with Scissors cutting Paper!"<<endl;
break;
}
else {
cout<<"Player2 made an invalid entry!!!"<<endl;
break;
}
}
else {
cout<<"Player1 made an invalid entry!"<<endl;
}
cout<<"Game over!"<<endl;
cout<<"Would you like to play again? Y for Yes, N for No";
cin>>exit;
} while ((exit!='n')||(exit!='N'));
//FINISH CODE/////////////////////////////
cout<<endl;
cout<<endl;
cout<<"End problem"<<endl;break;
} //End option 1
case 2:{
////////////////////////////////PROBLEM 2 Savitch Chp3Prb2//////////////////////
cout<<"Welcome to Option 2.";
cout<<endl;
//START CODE//////////////////////////////
//FINISH CODE/////////////////////////////
cout<<endl;
cout<<endl;
cout<<"End problem"<<endl;break;
} //End option 2
////////////////////////////////////////////////////////////////////////////////
case 15:{
////////////////////////////////PROBLEM 14 TRUTH TABLE//////////////////////////
cout<<"Welcome to Option 15.";
cout<<endl;
//START CODE//////////////////////////////
//FINISH CODE/////////////////////////////
cout<<endl;
cout<<endl;
cout<<"End problem"<<endl;break;
} //End option 15
////////////////////////////////////////////////////////////////////////////////
case 16: {
cout<<"Good Bye!"<<endl;break;
}
////////////////////////////////////////////////////////////////////////////////
} // switch statement end bracket
////////////////////////////////////////////////////////////////////////////////
} while (choose!=16); // do-while end bracket
////////////////////////////////////////////////////////////////////////////////
//Exit Stage Right
return 0;
}
|