here's my code. i wanted to display the name of the month instead of number. but there's an error in my code.
import java.util.Scanner;
import java.util.Date;
public class myIDCard{
public static void main(String[] args){
long myID;
long a,b,c,a1,a2,a3;
Scanner in = new Scanner(System.in);
System.out.print("Enter your Name: ");
String name = in.nextLine();
System.out.print("Enter your IC number without dash: ");
myID = in.nextLong();
in.nextLine();
a = myID/1000000;
b = myID/10000%100;
c = myID%10000;
a1 = a%100;
a2 = a/100%100;
a3 = a/10000;
String[] months = {"Jan", "Feb", "Mac", "Apr", "May", "Jun", "Jly", "Aug", "Sep", "Oct", "Nov", "Dis"};
String month = months[a2 - 1];
System.out.println();
System.out.println("Your name : " + name);
System.out.println("Your IC number : " + a + "-" + b + "-" + c);
System.out.println("Your Birth date : " + a1 + "/" + month + "/" + a3);
if (c % 2 == 0)
System.out.println("Your Gender is : Female");
else
System.out.println("Your Gender is : Male");
}
}
it said that "incompatible types: possible lossy conversion from long to int". the error in my code was:-
String month = months[a2 - 1];