Skip to content

Commit f863060

Browse files
Merge pull request #134 from Madhur-Jatiya/patch-1
RTO number plate generator
2 parents 695b580 + 86fa1ab commit f863060

File tree

1 file changed

+44
-0
lines changed

1 file changed

+44
-0
lines changed

src/Java/Random/RTO_number_plate.java

+44
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,44 @@
1+
public class RTO_number_plate {
2+
public static void main(String[] args) {
3+
String s = "MP09 CZ 9998";
4+
int n = 20;
5+
6+
String s1 = s.substring(0, 4);
7+
String s2 = s.substring(5, 7);
8+
String s3 = s.substring(8, 12);
9+
10+
int num = Integer.parseInt(s3);
11+
12+
for (int i = 0; i < n; i++) {
13+
System.out.print(s1 + " " + s2 + " ");
14+
System.out.format("%04d", num);
15+
System.out.println();
16+
17+
if (num != 9999) {
18+
num++;
19+
}
20+
21+
else {
22+
num = 0001;
23+
char ch1 = s2.charAt(0);
24+
char ch2 = s2.charAt(1);
25+
26+
if (ch2 == 'Z') {
27+
ch1++;
28+
ch2 = 'A';
29+
}
30+
31+
else {
32+
ch2++;
33+
}
34+
35+
s2 = String.valueOf(ch1) + String.valueOf(ch2);
36+
System.out.print(s1 + " " + s2 + " ");
37+
System.out.format("%04d", num);
38+
System.out.println();
39+
}
40+
41+
}
42+
43+
}
44+
}

0 commit comments

Comments
 (0)