import java.util.Scanner;
public class Main {
public static void main(String[] args) {
Scanner sc = new Scanner(System.in);
System.out.print("Enter Customer ID: ");
String id = sc.next();
// Check whether input has exactly 6 characters
if (id.length() != 6) {
System.out.println("X");
return;
}
String otp = "";
for (int i = 0; i < 6; i++) {
int digit = id.charAt(i) - '0';
// Check for odd digit
if (digit % 2 != 0) {
otp = otp + (digit * digit);
}
}
// If no odd digits
if (otp.length() == 0) {
System.out.println("X");
}
// If OTP has less than 4 digits
else if (otp.length() < 4) {
System.out.println("X");
}
// If OTP has exactly 4 digits
else {
// Print only first 4 digits
for (int i = 0; i < 4; i++) {
System.out.print(otp.charAt(i));
}
}
sc.close();
}
}⚠️Content was pasted as plain text and auto-formatted as a code block. Use the Code Block button in the editor for proper formatting.