Write a program to accept a number, check whether the numbers is prime number or not. If number is prime, then display “PRIME NUMBER” or display “NOT A PRIME NUMBER”.
class PrimeNum { public static void main(String args[]) { int i,f = 0; int n = Integer.parseInt(args[0]); for(i = 2;i<n;i++) { if(n%i = = 0) { f = 1; break; } } if(f = = 0) System.out.print ("The given no. "+n+" is a prime number"); else System.out.print ("The given no. "+n+" is not a prime number"); } }Create a list of names of 5 Country’s and then display name alphabetically.
public class CountrySort { public static void main() { String a[] = {"Germany", "Nepal", "India", "Pakistan", "Iraq"}; String k; int i,j; for(i = 0;i<4;i++) { for(j = 0;j<4-i;j++) { if(a[j].compareTo(a[j+1])>0) { k = a[j]; a[j] = a[j+1]; a[j+1] = k; } } } for(j = 0;j<5;j++) System.out.println (a[j]); } }- For more details Whats up num: 9173040728 or Email us: ictbopal@gmail.com