Q:

(Random character) Write a program that displays a random uppercase letter using the Math.random() method

0

(Random character) Write a program that displays a random uppercase letter using the Math.random() method.

All Answers

need an explanation for this answer? contact us directly to get an explanation for this answer

/*
(Random character) Write a program that displays a random uppercase letter
using the Math.random() method.
*/
public class Exercise_04_16 {
	public static void main(String[] args) {
		// Generate a random number between 65 and 90
		int number = 65 + (int)(Math.random() * (91 - 65));

		// Display a random uppercase letter
		System.out.println((char)(number));
	}
}

need an explanation for this answer? contact us directly to get an explanation for this answer

total answers (1)

Similar questions


need a help?


find thousands of online teachers now