4.16 (Random character) Write a program that displays a random uppercase letter using the Math.random() method.
![](https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEhVI3y7GzZ5-cemnN0Z52xAmFwYuguplu46RoRbkStGAk3Ks2oRpR81CIuf6WmvHG6_V7EhnSjrQRKPhYPUUmVtmFeR5-tQN19XbXUHiNtWtBLR10Fr0l9EnD-6hW-jcL41nyUDCBm5Czc/s1600/4-16.png)
![](https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEhVI3y7GzZ5-cemnN0Z52xAmFwYuguplu46RoRbkStGAk3Ks2oRpR81CIuf6WmvHG6_V7EhnSjrQRKPhYPUUmVtmFeR5-tQN19XbXUHiNtWtBLR10Fr0l9EnD-6hW-jcL41nyUDCBm5Czc/s1600/4-16.png)
public class ProgrammingEX4_16 { public static void main(String[] args) { int n = (int) (65 + Math.random() * 26); char c = (char) n; System.out.println("The random letter is " + c); } }
No comments :
Post a Comment