Related questions with answers
Question
Use the methods in the following program to print 100 uppercase letters and then 100 single digits, printing ten per line.
1 public class RandomCharacter {
2 /** Generate a random character between ch1 and ch2 */
3 public static char getRandomCharacter(char ch1, char ch2) {
4 return (char)(ch1 + Math.random() * (ch2 - ch1 + 1));
5 }
6
7 /** Generate a random lowercase letter */
8 public static char getRandomLowerCaseLetter() {
9 return getRandomCharacter('a', 'z');
10 }
11
12 /** Generate a random uppercase letter */
13 public static char getRandomUpperCaseLetter() {
14 return getRandomCharacter('A', 'Z');
15 }
16
17 /** Generate a random digit character */
18 public static char getRandomDigitCharacter() {
19 return getRandomCharacter('0', '9');
20 }
21
22 /** Generate a random character */
23 public static char getRandomCharacter() {
24 return getRandomCharacter('\u0000', '\uFFFF');
25 }
26 }
Solution
VerifiedAnswered 2 years ago
Answered 2 years ago
Step 1
1 of 4To print random uppercase letters and random digits we will need to use 2 methods. getRandomCharacter method will be used to generate characters. main method will call getRandomCharacter method and print results.
public class Main {
public static void main(String[] args) {}
public static char getRandomCharacter(char ch1, char ch2) {}
}
Create a free account to view solutions
By signing up, you accept Quizlet's Terms of Service and Privacy Policy
Create a free account to view solutions
By signing up, you accept Quizlet's Terms of Service and Privacy Policy
Recommended textbook solutions

Intro to Java Programming, Comprehensive Version
10th Edition•ISBN: 9780133761313Y. Daniel Liang1,628 solutions

Fundamentals of Database Systems
7th Edition•ISBN: 9780133970777Ramez Elmasri, Shamkant B. Navathe948 solutions

Introduction to Algorithms
3rd Edition•ISBN: 9780262033848Charles E. Leiserson, Clifford Stein, Ronald L. Rivest, Thomas H. Cormen872 solutions

Introduction to Algorithms
4th Edition•ISBN: 9780262046305Charles E. Leiserson, Clifford Stein, Ronald L. Rivest, Thomas H. Cormen945 solutions
More related questions
1/4
1/7