Navbar

Thursday, 11 April 2019

ISC COMPUTER SCIENCE PRACTICAL 2019 SOLVED

ISC COMPUTER SCIENCE PRACTICAL 2019

QUESTION 1:

Design a program to accept a day number (between 1 and 366), year(in 4 digits) from the user to generate and display the corresponding date. Also, accept ‘N’ ( 1<= N <= 100) from the user to compute and display  the future date corresponding to ‘N’ days after the generated date. Display an error message if the value of the day number, year and N are not within the limit or not according to the condition specified.
Test your program with the following data and some random data:
INPUT:

EXAMPLE 1: DAY NUMBER:                  255
                        YEAR:                                  2018
                        DATE AFTER (N DAYS):    22
OUTPUT:       DATE:                                   12 TH SEPTEMBER, 2018
                        DATE AFTER 22 DAYS      4 TH OCTOBER, 2018

Solution:

import java.util.*;
public class Date 
{
    public static void main(String[] args) 
{
       int day_num;
             int yr;
             int N;
        Scanner in = new Scanner(System.in);
        DaysCalculation date = new DaysCalculation();
        do 
      {
                    System.out.println("Enter a day number (between 1 and 366)");
                    day_num = in.nextInt();
                    if(day_num < 1 || day_num > 366)
                                 System.out.println("INVALID DAY NUMBER:");
                    }
      while(day_num < 1 || day_num > 366);
            
             do 
         {
                    System.out.println("Enter the year");
                    yr = in.nextInt();
                    if(Integer.toString(yr).length()!=4)
                                 System.out.println("INVALID YEAR:");
                    }
                       while(Integer.toString(yr).length()!=4);
             do  
                     {
                    System.out.println("Enter the value of N:");
                    N = in.nextInt();
                    if(N < 1 || N > 100)
                                 System.out.println("INVALID DAY NUMBER (between 1 and 100):");
                    }
                    while(N < 1 || N > 100);
           date.setDate(day_num,yr,N);  
           System.out.println("OUTPUT:");
           date.dateSpecifier(); 
          in.close();
        }   
    }
      class DaysCalculation  
       {
    public void setDate(int dayNumber, int year, int dayAfter) 
      {
        this.dayNumber = dayNumber;
        this.year = year;
        this.dayAfter = dayAfter;
        }
    public void dateSpecifier() 
       {
        int m = 0,k=1;
        for(int i = 1; i <= dayNumber; i++) 
             {
            if( checkLeap(year) == true ? k > ldays[m] : k > mdays[m] ) 
              {
                k = 1;
                m++;
                }
            k++;   
            }
        String prefix;   
        prefix = (k-1)%10 == 1 ? "st" : (k-1)%10 == 2 ? "nd" : (k-1)%10 == 3 ? "rd" : "th";
        System.out.println("DATE:     "+(k-1)+prefix+" "+months[m]+" ,"+year); 
        for (int i = 1; i <= dayAfter; i++) 
            {
            if( checkLeap(year) == true ? k > ldays[m] : k > mdays[m] ) 
               {
                k = 1;
                m++;
                if(m > 11) 
                   {
                    year++;
                    m = 0;
                    }
                }
            k++;   
            }
        prefix = (k-1)%10 == 1 ? "st" : (k-1)%10 == 2 ? "nd" : (k-1)%10 == 3 ? "rd" : "th";
        System.out.println("DATE AFTER "+dayAfter+" DAYS:"+(k-1)+""+prefix+" "+months[m]+"  ,"+year);       
        }   
    private boolean checkLeap(int year)  
         {
        if(year%400==0)
           leap=true;
        else if (year%100==0)
           leap=false;
        else if (year%4==0)
           leap=true;
        else
           leap=false;
           return leap;
        }    
    private boolean flag;
    private static boolean leap;   
    private int dayNumber,year;
    private int dayAfter;
    String[] months = {"January","Feburary","March","April","May","June","July","August","Sepetember","October","November","December"};
    int[] mdays={31,28,31,30,31,30,31,31,30,31,30,31};
    int[] ldays={31,29,31,30,31,30,31,31,30,31,30,31};   
    }

NOTE: THIS PROBLEM ALREADY CAME IN ISC 2009 COMPUTER SCIENCE PRACTICAL
-------------------end---------------------------

QUESTION 2:

Write a program to declare a single dimensional array a[] and a square matrix b[][]
of size N, where N > 2 and N < 10. Allow the user to input positive integers into
the single dimensional array.
Perform the following task on the matrix:

(a) Sort the elements of the single dimensional array in ascending order using any sorting technique
      and display the sorted elements.

(b)  Fill the matrix b[][] in the following format.
       If the array a[] ={5,2,8,1} then after sorting, a[]={1,2,5,8}
       then the matrix b[][] would fill as below:
                1   2   5   8
                1   2   5   1
                1   2   1   2
                1   1   2   5

(c)  Display the filled matrix in the above format

Test your program for some random data.
 Example 1:
INPUT N=3
            ENTER ELEMENTS OF SINGLE DIMENSIONAL ARRAY: 3 1 7

OUTPUT:  SORTED ARRAY :1 3 7
FILLED MATRIX
1 3 7
1 3 1
1 1 3

Solution:

import java.util.*;
class Matrix2019
{
public static void main(String args[])
{
Scanner sc=new Scanner(System.in);
System.out.println("Enter");
int N=sc.nextInt();
if(N<2||N>10)
{
System.out.println("MATRIX SIZE OUT OF RANGE");
}
else
{
int a[]=new int[1000];
int b[][]=new int[100][100];
System.out.println("ENTER ELEMENT OF SINGLE DIMENSIONAL ARRAY:");
for(int i=0;i<N;i++)
{
a[i]=sc.nextInt();
}
for(int i=0;i<N;i++)
{
for(int j=0;j<N-i-1;j++)
{
if(a[j]>a[j+1])
{
int temp=a[j];
a[j]=a[j+1];
a[j+1]=temp;
}
}
}
///for printing sorted array....
System.out.print("SORTED ARRAY :");
for(int i=0;i<N;i++)
{
System.out.print(a[i]);
}
for(int i=0;i<N;i++)
{
for(int j=0;j<N;j++)
{
if(j<N-i)
b[i][j]=a[j];
else
b[i][j]=a[j-(N-i)];
}
}
System.out.println("FILLED MATRIX");
for(int i=0;i<N;i++)
{
for(int j=0;j<N;j++)
{
System.out.print(b[i][j]);
}
System.out.println();
}
}
}
}
--------------end-----------------


Question 3

Write a program to accept a sentence which may be terminated by either '.', '?' or '!'
only. The words are to be entered by  a single blank space and re in UPPER CASE.

Perform the following tasks:
(a) Check for validity for the entered sentence.
(b) Convert the non-palindrome words of the sentence into palnidrome words by

      concatenating the word by its revers (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 become HELPLEH

  Note: The words which end with repeated alphabets, for example ABB would
             become ABBA and not ABBBA and XAZZZ becomes XAZZZAX.

(c) Display the original sentence along with 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 BIRDRID ISI FLYINGNIYLF
Example 2:
INPUT: YOU MUST BE CRAZY#
OUTPUT: INVALID INPUT

Solution:

import java.util.*;
class MakePalindrome
{
   private String s,rs;
   public MakePalindrome()
   {
       s="";
       rs="";
    }
    public Boolean input()
    {
        int l;
        char ch;
        Scanner sc=new Scanner(System.in);
        System.out.println("enter the Sentence");
        s=sc.nextLine();
        l=s.length();
        ch=s.charAt(l-1);
        if(!(ch=='.'||ch=='?'||ch=='!'))
        {
            System.out.println("INVALID INPUT");
            return false;
        }
        else
        {
            return true;
        }
    }
    public void process()
    {
        String w,suffix;
        int l,wl,i;
        char ch;
        l=s.length();
        ch=s.charAt(l-1);
        String ns=s.substring(0,l-1);
        StringTokenizer st = new StringTokenizer(ns);
        while(st.hasMoreTokens())
        {
            w=st.nextToken();
            wl=w.length();
            i=0;
            suffix="";
            while(!isPalindrome(w+suffix))
            {
                suffix = w.charAt(i) + suffix;
                i++;
            }
            rs=rs + " " + w+suffix;
        }
        rs =rs.substring(l);
    }
    public void display()
    {
        System.out.println("Result is:");
        System.out.println(rs);
    }
    public boolean isPalindrome(String s)
    {
        String r="";
        int l,i;
        l=s.length();
        for(i=0;i<l;i++)
        {
            r=s.charAt(i) +r;
        }
        return s.equals(r);
    }
    public static void main(String args[])
    {
        MakePalindrome ob = new MakePalindrome();
        if(ob.input())
        {
            ob.process();
            ob.display();
        }
    }
}
------------------end-----------------------

3 comments:

  1. As claimed by Stanford Medical, It's in fact the one and ONLY reason women in this country get to live 10 years more and weigh an average of 19 KG lighter than us.

    (And really, it has NOTHING to do with genetics or some hard exercise and absolutely EVERYTHING to related to "how" they are eating.)

    BTW, What I said is "HOW", and not "WHAT"...

    Click on this link to find out if this little quiz can help you unlock your real weight loss possibility

    ReplyDelete
  2. Bro,your code of third program doesn't give the right output as is required by the question.
    And problem in code is in method "process" in line 'rs=rs.substring(l)'.Here, this line is of no use. So ,you should remove it from the code.And write the line 'rs=rs.trim()' there for accurate answer as per the question need.

    ReplyDelete
  3. LEGIT FULLZ & TOOLS STORE

    Hello to All !

    We are offering all types of tools & Fullz on discounted price.
    If you are in search of anything regarding fullz, tools, tutorials, Hack Pack, etc
    Feel Free to contact

    ***CONTACT 24/7***
    **Telegram > @leadsupplier
    **ICQ > 752822040
    **Skype > Peeterhacks
    **Wicker me > peeterhacks

    "SSN LEADS/FULLZ AVAILABLE"
    "TOOLS & TUTORIALS AVAILABLE FOR HACKING, SPAMMING,
    CARDING, CASHOUT, CLONING, SCRIPTING ETC"

    **************************************
    "Fresh Spammed SSN Fullz info included"
    >>SSN FULLZ with complete info
    >>CC With CVV (vbv & non vbv) Fullz USA
    >>FULLZ FOR SBA, PUA & TAX RETURN FILLING
    >>USA I.D Photos Front & Back
    >>High Credit Score fullz (700+ Scores)
    >>DL number, Employee Details, Bank Details Included
    >>Complete Premium Info with Relative Info

    ***************************************
    COMPLETE GUIDE FOR TUTORIALS & TOOLS

    "SPAMMING" "HACKING" "CARDING" "CASH OUT"
    "KALI LINUX" "BLOCKCHAIN BLUE PRINTS" "SCRIPTING"
    "FRAUD BIBLE"

    "TOOLS & TUTORIALS LIST"
    =>Ethical Hacking Ebooks, Tools & Tutorials
    =>Bitcoin Hacking
    =>Kali Linux
    =>Fraud Bible
    =>RAT
    =>Keylogger & Keystroke Logger
    =>Whatsapp Hacking & Hacked Version of Whatsapp
    =>Facebook & Google Hacking
    =>Bitcoin Flasher
    =>SQL Injector
    =>Premium Logs (PayPal/Amazon/Coinbase/Netflix/FedEx/Banks)
    =>Bitcoin Cracker
    =>SMTP Linux Root
    =>Shell Scripting
    =>DUMPS with pins track 1 and 2 with & without pin
    =>SMTP's, Safe Socks, Rdp's brute
    =>PHP mailer
    =>SMS Sender & Email Blaster
    =>Cpanel
    =>Server I.P's & Proxies
    =>Viruses & VPN's
    =>HQ Email Combo (Gmail, Yahoo, Hotmail, MSN, AOL, etc.)

    *Serious buyers will always welcome
    *Price will be reduce in bulk order
    *Discount offers will give to serious buyers
    *Hope we do a great business together

    ===>Contact 24/7<===
    ==>Telegram > @leadsupplier
    ==>ICQ > 752822040
    ==>Skype > Peeterhacks
    ==>Wicker me > peeterhacks

    ReplyDelete