Difference: CSC121F2024Lab02Hint03 (1 vs. 2)

Revision 22024-09-03 - CathyBareiss

Line: 1 to 1
 
META TOPICPARENT name="CSC121F2024Lab02"

Hint 3 on random numbers for Lab 2 (Fall 2024)

Here is program that will print a random integer between 0 and 10:
Line: 11 to 11
  int number;

generator = new Random();

Changed:
<
<
number generator.nextInt(10);
>
>
number = generator.nextInt(10);
  System.out.println(number); } }

Revision 12024-06-04 - CathyBareiss

Line: 1 to 1
Added:
>
>
META TOPICPARENT name="CSC121F2024Lab02"

Hint 3 on random numbers for Lab 2 (Fall 2024)

Here is program that will print a random integer between 0 and 10:
import java.io.*;
import java.util.*;
public class RandomDemo {
    public static void main(String[] args) {
        Random generator;
        int number;

        generator = new Random();
        number generator.nextInt(10);
        System.out.println(number);
    }
}
 
This site is powered by the TWiki collaboration platform Powered by PerlCopyright © 2008-2026 by the contributing authors. All material on this collaboration platform is the property of the contributing authors.
Ideas, requests, problems regarding TWiki? Send feedback