Tuesday, November 19, 2019

ISC COMPUTER SCIENCE QUESTION PRACTICAL PAPER 2019 | QUESTION NUMBER 2 | Follow on youtube for more |




import java.util.*;
public class qstn_2
{
public static void main(String[] args)
{
Scanner sc = new Scanner(System.in);
System.out.println("Enter the number of elements");
int n = sc.nextInt();

if(n<=2||n>=10)
{
System.out.println("MATRIX SIZE OUT OF RANGE");
System.exit(0);
}

int a[] =new int[n];
//Taking array input
System.out.println("ENTER ELEMENTS OF SINGLE DIMENSIONAL ARRAY:");
for(int i=0;i<n;i++)
{
a[i] = sc.nextInt();
}

//sorting the array elements

int temp = 0;
for(int i=0;i<n;i++)
{
for(int j=0;j<n;j++)
{
if(a[i]<a[j])
{
temp = a[i];
a[i] = a[j];
a[j] = temp;
}
}
}

// Displaying the sorted array
System.out.print("\nSORTED ARRAY: ");
for(int i=0;i<n;i++)
{
System.out.print(a[i]+" ");
}

System.out.println();
int row = n;
int column = n;
int position = 0;

System.out.println("\nFILLED MATRIX");
for(int i=0;i<row;i++)
{
for(int j=0;j<column;j++)
{
System.out.print(a[j]+" ");
}
for(int j=0;j<position;j++)
{
System.out.print(a[j]+" ");
}
System.out.println();
position++;
column--;
}
}
}

ISC COMPUTER SCIENCE QUESTION PRACTICAL PAPER 2018 | QUESTION NUMBER 2 | Follow on youtube for more |





import java.util.Scanner;
public class qstn_2
{
public static void sort(int a[])
{
int temp = 0;
for(int i =0;i<a.length;i++)
{
for(int j =0;j<a.length;j++)
{
if(a[i]<a[j])
{
temp = a[i];
a[i] = a[j];
a[j] = temp;
}
}
}

for(int i =0;i<a.length;i++)
{
System.out.print(a[i]+" ");
}
System.out.println();
}
public static void main(String[] args)
{
Scanner sc = new Scanner(System.in);
System.out.println("Enter the matrix size");
System.out.print(" M = ");
int m =  sc.nextInt();
System.out.print(" N = ");
int n = sc.nextInt();
int input[][]  = new int[m][n];

// boundary case
if(n<=2||n>=10||m<=2||m>=10)
{
System.out.println("MATRIX SIZE OUT OF RANGE");
System.exit(0);
}

System.out.println("Enter elements of the matrix");
for(int i=0;i<m;i++)
{
for(int j=0;j<n;j++)
{
input[i][j] = sc.nextInt();
}
}
System.out.println("ORIGINAL MATRIX");
for(int i=0;i<m;i++)
{
for(int j=0;j<n;j++)
{
System.out.print(input[i][j]+" ");
}
System.out.println();

}


int insert = 0;
System.out.println("\nMATRIX AFTER SORTING ROWS");
for(int i=0;i<m;i++)
{
int arr[] = new int[n];
for(int j=0;j<n;j++)
{
arr[insert++] = input[i][j];
}
sort(arr);
insert = 0;
}
sc.close();
}
}

ISC COMPUTER SCIENCE QUESTION PRACTICAL PAPER 2017| QUESTION NUMBER 2 | Follow on YOUTUBE for more |




import java.util.Scanner;
public class qstn_2
{
public static void main(String[] args)
{
Scanner sc = new Scanner(System.in);
System.out.println("Enter the number of participants");
int n = sc.nextInt();

if(n<3 || n>11)
{
System.out.println("INPUT SIZE OUT OF RANGE");
System.exit(0);
}

String a[][] = new String[n][5];
for(int i=0;i<n;i++)
{
System.out.println("Participants "+(i+1));
for(int j=0;j<5;j++)
{

a[i][j] = sc.next();

}

}
System.out.println("\nKey : ");
String answer[] = new String[5];
for(int i=0;i<5;i++)
{
answer[i] = sc.next();
}

int score[] = new int[5];
int count  = 0;
int insert = 0;
int max = 0;
for(int i=0;i<n;i++)
{
for(int j=0;j<5;j++)
{
if(a[i][j].equalsIgnoreCase(answer[j]))
{
count++;
}
}

if(max<count)
max = count;

score[insert++] = count;
count=0;


}
System.out.println();
for(int i = 0;i<n;i++)
{
System.out.println("Participants "+(i+1)+" = "+score[i]);
}

System.out.println("\nHighest Score :");

for(int i = 0;i<n;i++)
{
if(max==score[i])
System.out.println("Participant "+(i+1));

}
}
}

Thursday, November 7, 2019

ISC COMPUTER SCIENCE QUESTION PRACTICAL PAPER 2017| QUESTION NUMBER 3 | Follow on YOUTUBE for more |




import java.util.*;
public class qstn_3
{
public static void main(String[] args)
{
Scanner sc  = new Scanner(System.in);

//Taking user input
System.out.println("Enter the sentence");
String s = sc.nextLine();

//For lowercase characters
String low = "abcdefghijklmnopqrstuvwxyzabcdefghijklm";

//For Uppercase characters
String cap = "ABCDEFGHIJKLMNOPQRSTUVWXYZABCDEFGHIJKLM";

//Taking the length of input string
int length = s.length();

//To check for the boundary condition
if(length<4||length>99)
{
System.out.println("INVALID LENGTH");
System.exit(0);
}
//For the new word
String new_word = "";

for(int i=0;i<length;i++)
{
//Extracting
char c = s.charAt(i);

//Checking for the uppercase character
if(Character.isUpperCase(c))
{
//To get the position of the character
//so that you can encode it.
for(int j = 0;j<cap.length();j++)
{

char c1 = cap.charAt(j);

//To compare both the characters
//to check if they are equal
if(c==c1)
{

//Increasing the character by 13 position
char lower_case = cap.charAt(j+13);

//Storing the new character
new_word+=lower_case;//new_word = new_word+lower_case;
break;
}
}
}

//Checking for the lowercase character
else if(Character.isLowerCase(c))
{
//To get the position of the character
//so that you can encode it.
for(int j = 0;j<low.length();j++)
{
char c1 = low.charAt(j);

//To compare both the characters
//to check if they are equal
if(c==c1)
{

//Increasing the character by 13 position
char upper_case = low.charAt(j+13);

//Storing the new character
new_word+=upper_case;
break;
}
}
}

//For exclaimation mark character
else if(c=='!')
{
new_word+="?";
}

//For any other characters
else
{
new_word+=c;
}
}

//Result output
System.out.println("\nThe cipher text is:");
System.out.println(new_word);
}
}

ISC COMPUTER SCIENCE QUESTION PRACTICAL PAPER 2017| QUESTION NUMBER 1 | Follow on youtube for more |



import java.util.*;
public class qstn_1
{
public static void main(String[] args)
{
Scanner sc = new Scanner(System.in);
System.out.println("Enter the input ");
int n = sc.nextInt();
int n1 = n;
int count = 0;
if(n>1000)
{
System.out.println("INVALID INPUT");
System.exit(0);
}

if(n>=48)
{
int div = n/48;
n = n-div*48;
count = count + div;
}

if(n>=24)
{
int div = n/24;
n = n-div*24;
count = count + div;
}

if(n>=12)
{
int div = n/12;
n = n-div*12;
count = count + div;
}

if(n>=6)
{
int div = n/6;
n = n-div*6;
count = count + div;
}

System.out.println("Remaining boxes = "+n);
if(n!=0)
{
count++;
}
System.out.println("Total number of boxes = "+n1);
System.out.println("Total number of cartons =  "+count);

}
}

Sunday, November 3, 2019

ISC COMPUTER SCIENCE QUESTION PRACTICAL PAPER 2018 | QUESTION NUMBER 3 | Follow on youtube for more |



import java.util.*;
public class qstn_3
{
public static void main(String[] args)
{
Scanner sc = new Scanner(System.in);
System.out.println("Enter the number of words");
int n = sc.nextInt();

//To shift the command to next line as after an integer input when we take a string
        // input the command does not shift to next line and is rather skipped.
        //It does not read the newline character in your input created by hitting "Enter,"
sc.nextLine();

//Boundary cases
if(n<2 && n>9)
{
System.out.println("Invalid Input");
System.exit(0);
}
// word array
String s[] = new String[n];

// length array
int length[] = new int[n];

for(int i = 0;i<n;i++)
{

// taking the string input 
s[i] = sc.nextLine();



// length of each word stored in the array
length[i] = s[i].length();
}
int j = 0;
String k = "";
int flag = 0;

// infinite loop as we don't know the length of
// maximum word.
while(true)
{

// Running the loop for each word
for(int i = 0;i<n;i++)
{

// This will check if the length is not zero
if(length[i]!=0)
{

// We extract the character
char c = s[i].charAt(j);

//We store the character in the variable with a space
k = k+c+" ";

// We decrease the length
length[i]--;

// A check variable for exit condition
flag++;
}

// If there are no character, we just add two spaces.
else
{
k = k+"  ";
}
}
// We increase the character position
j++;

// Display of the words
System.out.println(k);

// Erasing the word for next loop
k="";

//Exit condition when no more character in any word
if(flag==0)
{
System.exit(0);
}

//Initializing the flag to zero for next loop
flag = 0;
}
}
}

Friday, November 1, 2019

ISC COMPUTER SCIENCE QUESTION PRACTICAL PAPER 2018 | QUESTION NUMBER 1 | GOLDBACH NUMBER | Follow on youtube for more |



import java.util.*;
public class qstn_1
{
public static int check(int n,int pos,int input)
{

int result=0;
int prime[] = {2,3,5,7,11,13,17,19,23,29,31,37,41,43,47};
for(int i = pos;i<prime.length;i++)
{
int sum = n+prime[i];
if(sum==input)
{
result= prime[i];
break;
}
sum = 0;
}
return result;
}
public static void main(String[] args)
{
Scanner sc = new Scanner(System.in);
System.out.println("Enter the number");
int n = sc.nextInt();
// boundary conditions
if(n<9 || n>50)
{
System.out.println("INVALID INPUT. NUMBER OUT OF RANGE.");
System.exit(0);
}
if(n>1 && n%2!=0)
{
System.out.println("INVALID INPUT. NUMBER IS ODD.");
System.exit(0);
}
int prime[] = {2,3,5,7,11,13,17,19,23,29,31,37,41,43,47};
int n1[] = new int[10];
int n2[] = new int[10];
int ins1 = 0,ins2 = 0;
int length = prime.length;
int pos = 0;
int result=0;
int pos2 = 0;
while(length!=0)
{
pos2 = pos;
result = check(prime[pos],pos++,n);
if(result!=0)
{
n1[ins1++] = prime[pos2];// number sending
n2[ins2++] = result; // result from function
}
length--;
}
for(int i=0;i<ins1;i++)
{
System.out.println(n1[i]+", "+n2[i]);
}
}
}

ICSE COMPUTER SCIENCE SPECIMEN PAPER | QUESTION 7 | PLEASE DO WATCH THE VIDEO

  import  java.util.*; class icse_specimen_1 {     public static void main(String[] args)     {         Scanner sc1 = new Scanner(System.in)...