Question: 1. Create a subclass of Random class. Your subclass will have the following methods and add one more your own method. public char nextChar() public

1. Create a subclass of Random class. Your subclass will have the following methods and add one more your own method.

public char nextChar() public char nextChar(char l, char h) public int nextSequence(int l, int h)

2. Create a main program to test all the above methods in the subclass. Please refer to the skeleton file(newRandomGenerator_Skeleton.java).

public class newRandomGenerator_Skeleton { public static void main(String[] args) {

System.out.println(); System.out.println("nextChar():"); for (int i=0; i<5;i++){ char c1 = rand.nextChar(); System.out.println(c1); }

System.out.println(); System.out.println("nextChar('A','C'):"); for (int i=0; i<5;i++){ char c2 = rand.nextChar('A','C'); System.out.println(c2); }

System.out.println(); System.out.println("nextChar('Y','C'):"); for (int i=0; i<5;i++){ char c2 = rand.nextChar('Y','C'); System.out.println(c2); }

System.out.println(); System.out.println("nextSequence(1,6):"); for (int i=0; i<5;i++){ int ns = rand.nextSequence(1,6); System.out.println(ns); }

} }

[Sample Output]

----jGRASP exec: java newRandomGenerator_Skeleton

nextChar(): Z K J U O

nextChar('A','C'): C C B C A

nextChar('Y','C'): Y B Y A C

nextSequence(1,6): 2 1 4 5 2

----jGRASP: operation complete.

Step by Step Solution

There are 3 Steps involved in it

1 Expert Approved Answer
Step: 1 Unlock blur-text-image
Question Has Been Solved by an Expert!

Get step-by-step solutions from verified subject matter experts

Step: 2 Unlock
Step: 3 Unlock

Students Have Also Explored These Related Databases Questions!