GTU OOP Program - 7
7). Assume a vehicle plate number consists of three uppercase letters followed by four digits. Write a program to generate a plate number.
class Program_07 { public static void main(String[] args) { int letter1 = 65 + (int) (Math.random() * (90 - 65)); int letter2 = 65 + (int) (Math.random() * (90 - 65)); int letter3 = 65 + (int) (Math.random() * (90 - 65)); // Generating four random numbers int num1 = (int) (Math.random() * 10); int num2 = (int) (Math.random() * 10); int num3 = (int) (Math.random() * 10); int num4 = (int) (Math.random() * 10); // Display number System.out.print("" + (char) (letter1) + ((char) (letter2)) + ((char) (letter3)) + num1 + num2 + num3 + num4); } }
Output
Comments