Showing posts with label ISC 2019 practical question. Show all posts
Showing posts with label ISC 2019 practical question. Show all posts

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--;
}
}
}

Sunday, October 20, 2019

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


3. Write a program to accept a sentence which may be terminated by either ‘.’ , ‘?’ or
‘!’ only. The words are to be separated by a single blank space and are in UPPER
CASE.
Perform the following tasks:
(a) Check for the validity of the accepted sentence.

(b) Convert the non-palindrome words of the sentence into palindrome words by
concatenating the word by its reverse (excluding the last character).
Example: The reverse of the word HELP would be LEH (omitting the last
alphabet) and by concatenating both, the new palindrome word is
HELPLEH. Thus, the word HELP becomes HELPLEH.
Note: The words which end with repeated alphabets, for example ABB
would become ABBA and not ABBBA and XAZZZ becomes
XAZZZAX.
[Palindrome word: Spells same from either side. Example: DAD, MADAM etc.]

(c) Display the original sentence along with the converted sentence.
Test your program for the following data and some random data:

Example 1
INPUT: THE BIRD IS FLYING.
OUTPUT: THE BIRD IS FLYING.
THEHT BIRDRIB ISI FLYINGNIYLF

Example 2
INPUT: IS THE WATER LEVEL RISING?
OUTPUT:  IS THE WATER LEVEL RISING?
                  ISI THEHT WATERETAW LEVEL RISINGNISIR

Example 3
INPUT: THIS MOBILE APP LOOKS FINE.
OUTPUT: THIS MOBILE APP LOOKS FINE.
                  THISIHT MOBILELIBOM APPA LOOKSKOOL FINENIF

Example 4 INPUT: YOU MUST BE CRAZY#
OUTPUT: INVALID INPUT

import java.util.*;
public class qstn_2
{
static String palincheck(String word)
{
int flag = 0;
String s1 = "",s2 = "",s3 = "";
String result = "";
// Reversing the word.
for(int i=word.length()-1;i>=0;i--)
{
char c = word.charAt(i);
s1 = s1+c;
}
//Compare the reverse word with original word.
if(s1.equalsIgnoreCase(word))
{
flag=1;
}

//When the word is not palindrome.
if(flag!=1)
{
int l  = word.length();
char last_char = word.charAt(l-1);
int dupli_length = 0;
int count = 0;

//To get the length when the word has repeated
//character ending
for(int i = l-1;i>=0;i--)
{
char c1 = word.charAt(i);
if(last_char==c1)
{
count++;
dupli_length = i;
}
//So that only last repeated character 
else
break;

}
//Change the length when the characters
//have repeated ending.
if(count<=1)
{
dupli_length  = l;
}
//We increase it  by 1 for array indexing purposes.
if(count>1)
{
dupli_length++;
}

for(int i = 0;i<dupli_length-1;i++) // hello hell lleh
{
char c = word.charAt(i);
s2=c+s2;
}
s3 = word+s2;
result = s3;
}
return result;
}
public static void main(String[] args)
{
Scanner sc = new Scanner(System.in);
System.out.println("Enter the sentence");
String s = sc.nextLine();
int l = s.length();
String words[] = new String[100];
String k = "";
int ins = 0;
if(s.charAt(l-1)=='?'||s.charAt(l-1)=='.'||s.charAt(l-1)=='!')
{
for(int i = 0;i<l;i++)
{
char c = s.charAt(i);
if(c==' '||c=='?'||c=='.'||c=='!')
{
words[ins++] = k;
k = "";
}
else 
{
k = k+c;
}
}
for(int i = 0;i<ins;i++)
{
String w = palincheck(words[i]);
words[i] = w;
}
System.out.println(s);
for(int i =0;i<ins;i++)
System.out.print(words[i]+" ");
}
else
System.out.println("INVALID INPUT");
}
}

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)...