Code is copied!
Program to input a word and convert it into uppercase then print only characters at prime indexes JAVA
Write a Program to input a word and convert it into uppercase then print only characters at prime indexes.
import java.util.Scanner; class primeprint { public static void main() { Scanner sc = new Scanner(System.in); System.out.println("Enter a String"); String s = sc.next().toUpperCase(); int c =0; for(int i =2;i< s.length();i++) { for(int j =1;j<=i;j++) { if(i%j==0) c++; } if(c==2) System.out.print(s.charAt(i)); c=0; } } }