Home | | Schedule | | Assignments | | Lectures | | Resources
//*********************************************************************** // lotto.cc // Author: Constance Royden/Laurie King // Date: February 23, 2014 // Class: CSCI 131 // Purpose: This program generates lottery numbers // Input: (from standard input) an integer // Output: (to standard output) a listing of lottery numbers //*********************************************************************** #include <iostream> #include <cmath> using namespace std; int Random ( long int& ); int main( void ) { long int myseed; int numPeople; int count; // ASSIGN THE VARIABLE myseed A VALUE HERE myseed = 34543; // INSERT PROGRAM CODE HERE cout << "How many people need lottery numbers? "; cin >> numPeople; cout << "Your lucky lottery numbers for the day are: " << endl; cout << "Pick 3 Pick 4 Pick 6"; for ( count = 0; count < numPeople*13; count++) { if ((count % 13) == 0) { cout << endl; } else if ((count % 13) == 3 ) { cout << " "; } else if ((count % 13) == 7) { cout << " "; } cout << Random(myseed) << " "; } cout << endl; } // main //************************************************************ // int Random ( long int& seed ) // Purpose: produces a pseudo-random number // Postcondition: returns a pseudo-random number in (0,1) //************************************************************ int Random ( long int& seed ) // seed for the random number generator { const long int MODULUS = 65536; const int MULTIPLIER = 25173; const int INCREMENT = 13849; seed = (MULTIPLIER * seed + INCREMENT) % MODULUS; return (1 + int(9 * (double(seed) / double(MODULUS)))); } // Random
Home | | Schedule | | Assignments | | Lectures | | Resources
CSCI 131: Techniques of Programming
Last Modified: February 23, 2014
Page Expires: October 12, 2014