Prime Adam Isc Class 12 Computer Science
Prime Adam Isc Class 12 Computer Science
import java.util.*;
class prime_adam
{
int reverse(int num)
{
int rev=0;
while (num!=0)
{
int d=num%10;
rev=rev*10+d;
num/=10;
}
return rev;
}
int count=0;
if(m>=n)
{
System.out.println("INVALID INPUT");
System.exit(0);
}
if (count==0)
System.out.println("NIL");
ARRANGE WORD
import java.util.*;
class arrangeword
{
int c;
public void disp(String s)
{
int i=0; String temp=" ";
StringTokenizer st= new StringTokenizer(s,"?,.! ");
c=st.countTokens();
String a[]= new String[c];
while(st.hasMoreTokens())
{
a[i]=st.nextToken();
i++;
}
for( i=0;i<c;i++)
{
for(int j=0;j<c-1-i;j++)
{
if(a[j].length()>a[j+1].length())
{
temp=a[j];
a[j]=a[j+1];
a[j+1]=temp;
}
if(a[j].length()==a[j+1].length())
{
if(a[j].compareTo(a[j+1])>0)
{
temp=a[j];
a[j]=a[j+1];
a[j+1]=temp;
}
}
}
}
for(i=0;i<c;i++)
{
System.out.print(a[i]+" ");
}
}
}
CIRCULAR PRIME
import java.util.Scanner;
public class CircularPrime
{
public static boolean isPrime(int num) {
int c = 0;
for (int i = 1; i <= num; i++) {
if (num % i == 0) {
c++;
}
}
return c == 2;
}
while (num != 0) {
c++;
num /= 10;
}
return c;
}
if (n <= 0) {
System.out.println("INVALID INPUT");
return;
}
if (isCircularPrime) {
System.out.println(n + " IS A CIRCULAR PRIME.");
}
else {
System.out.println(n + " IS NOT A CIRCULAR PRIME.");
}
}
}
MATRIX SORTING
import java.util.Scanner;
public class MatrixSort
{
public static void main(String args[]) {
Scanner in = new Scanner(System.in);
System.out.print("ENTER MATRIX SIZE (M): ");
int m = in.nextInt();
System.out.println("ORIGINAL MATRIX");
printMatrix(a, m);
sortNonBoundaryMatrix(a, m);
System.out.println("REARRANGED MATRIX");
printMatrix(a, m);
computePrintDiagonalSum(a, m);
}
k = 0;
for (int i = 1; i < m - 1; i++) {
for (int j = 1; j < m - 1; j++) {
a[i][j] = b[k++];
}
}
}
while (st.hasMoreTokens()) {
String word = st.nextToken();
int wordLen = word.length();
if (isVowel(word.charAt(0))
&& isVowel(word.charAt(wordLen - 1))) {
c++;
sbVowel.append(word);
sbVowel.append(" ");
}
else {
sb.append(word);
sb.append(" ");
}
}
return ret;
}
}
QUIZ
import java.util.Scanner;
public class QuizCompetition
{
public static void main(String args[]) {
Scanner in = new Scanner(System.in);
System.out.print("Enter the Number of Participants (N): ");
int n = in.nextInt();
int hScore = 0;
int score[] = new int[n];
System.out.println("Scores:");
for (int i = 0; i < n; i++) {
for (int j = 0; j < 5; j++) {
if (answers[i][j] == key[j]) {
score[i]++;
}
}
System.out.println("Highest Score:");
for (int i = 0; i < n; i++) {
if (score[i] == hScore) {
System.out.println("Participant " + (i+1));
}
}
}
}
CAESAR CIPHER
import java.util.Scanner;
public class CaesarCipher
{
public static void main(String args[]) {
Scanner in = new Scanner(System.in);
System.out.println("Enter plain text:");
String str = in.nextLine();
int len = str.length();
BANNER
import java.util.Scanner;
else {
System.out.print(teams[j].charAt(i) + "\t");
}
}
System.out.println();
}
}
public class Banner
{
public static void main(String args[]) {
Scanner in = new Scanner(System.in);
System.out.print("ENTER THE VALUE OF N: ");
int n = in.nextInt();
in.nextLine();
if (n <= 2 || n >= 9) {
System.out.println("INVALID INPUT");
return;
}