In: Computer Science
Write a loop to print a list of numbers starting at 64 and ending at 339. Justify your syntax. in java
PLEASE GIVE IT A THUMBS UP, I SERIOUSLY NEED ONE, IF YOU NEED ANY MODIFICATION THEN LET ME KNOW, I WILL DO IT FOR YOU
I first converted the number to string and then
extracted first part and last part from string and then converted
back to integer and compared and given the output
class A{
  public static void main(String[] args) {
    int num[] = {645678339, 65346339, 64234338, 64256339, 64339 };
    for(int i=0;i<num.length;i++){
      String s = num[i]+"";
      String s2 = ""+s.charAt(0)+s.charAt(1);
      int st = Integer.parseInt(s2);
      String s1 = ""+s.charAt(s.length()-3) + s.charAt(s.length()-2) + s.charAt(s.length()-1);
      int end = Integer.parseInt(s1);
      if(st == 64 && end==339)
        System.out.println(s);
    }
  }
}