Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- // Random Number Program
- //CS211 HW1 program 11
- //Prof. Craig Niiyama Date: 04-10-10
- package edu.bellevuecollege.css211.random;
- import java.io.IOException;
- import java.io.InputStream;
- public class random {
- public static int randomNumber(int seed)
- {
- return (40 * seed + 3641) % 729;
- }
- /**
- * @param args
- * @throws IOException
- */
- public static void main(String[] args) throws IOException {
- // TODO Auto-generated method stub
- //program welcome message for user
- // prompt user for first number input
- System.out.println("Welcome to random number generator. ");
- System.out.println("Please enter the first number to generate: ");
- int seed = System.in.read();
- seed = randomNumber(seed);
- //calculate the random integers
- // output the first random number
- System.out.println("This is your first random number:" + seed);
- //prompt user to continue of exit program
- // outputs the next random number
- System.out.println("Would you like to see the next number (y,n): ");
- char key = (char)System.in.read();
- if (key == 'y'){
- seed = randomNumber(seed);
- System.out.println("Next random number is:" + seed);
- }
- else {
- System.out.println("Goodbye.");
- }
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement