Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- //I'm fairly new to C++, please excuse the bad code. Just put this program into your compiler of choice, and let the hilarity ensue!
- #include <iostream>
- #include <string>
- #include <cstdlib>
- #include <ctime>
- using namespace std;
- int random(int min, int max); //range : [min, max)
- int main()
- {
- string noun [10] = {"paper ", "tray ", "user ", "button ", "ink ", "toner ", "rack ", "spooler ", "printer ", "feeder "};
- string fault [10] = {"jam", "error", "fault", "overload", "spill", "failure", "spill", "low ", "leak ", "malfunction "};
- string action [10] = {"remove ", "reset ", "recalibrate ", "push ", "adjust ", "reload ", "dislodge ", "insert ", "retrieve ", "feed "};
- bool keepgoing = true;
- char ch;
- while (keepgoing == true)
- {
- for(int i = 0; i < 10; i++)
- {
- cout << "Error: ";
- cout << noun[random(0, 10)];
- cout << fault[random(0,10)] << ": ";
- cout << "Please ";
- cout << action[random(0,10)];
- cout << noun[random(0, 10)] << endl;
- }
- cout << endl << "Press enter to generate more error messages";
- cin.get(ch);
- }
- return 0;
- }
- //note to self: learn what this actually does.
- int random(int min, int max) //range : [min, max)
- {
- static bool first = true;
- if ( first )
- {
- srand(time(NULL)); //seeding for the first time only!
- first = false;
- }
- return min + rand() % (max - min);
- }
Advertisement
Add Comment
Please, Sign In to add comment