Home / JAVA / ISC Class 12 (page 2)

ISC Class 12

Bluej/Java program for spiral matrix

This is a java program for spiral matrix. import java.util.*; //for importing scanner class class spiral { public static void main(String args[]) { Scanner obj=new Scanner(System.in); //can also be done by BufferReader. But then use: import.java.io.*; System.out.print("\nEnter the size of matrix (nxn):"); int n=obj.nextInt(); int a[][]=new int[n][n]; System.out.println("Your matrix is of order "+n+"x"+n+"\n"); int d,c,i,j,l,t,m,k; d=n-1; c=n*n+1; // if its ...

Read More »

Java Program to check for a Magic Number

This is a Java program for Magic number. However before starting let me tell you what is a magic number. A Magic number is a number whose sum of digits eventually leads to 1. Example#1:  19 ;  1+9 =10 ; 1+0 = 1.  Hence a magic number. Example#2:  226; 2+2+6=10; 1+0 =1.  Hence a magic number. Example#3:  874; 8+7+4=19; 1+9=10; 1+0=1. ...

Read More »

Program for smith number in Java

This is a program in java to check whether a number is a  or not. import java.io.*; class smithnumber { static int sumdigit(int x) //to find the sum of digits { int sum=0; if(x!=0) sum+=x%10+sumdigit(x/10); return sum; } static int sumfact(int x) { int i,fact=0; for(i=2;i<=x;i++) { if(prime(i)) { while(x%i==0) { fact+=sumdigit(i); x/=i; } } } return fact; } static ...

Read More »

Java program to translate english to piglatin form

This is a program to convert a english word into piglatin form: Piglatin form: Any word is converted into piglatin form by starting the word from the first vowel and adding the remaining part in the end followed by “AY” import java.io.*; class piglatin { public static void main(String args[])throws Exception { String a; char c;int i,l; System.out.println("Enter a word"); ...

Read More »