Posts

Showing posts from April, 2017

[Question 5] ICSE 2016 Computer Application Solved - Pattern

Image
Question 5. Using the switch statement, write a menu driven program for the following: (i) To print the Floyd’s triangle [Given below] 1 2  3 4  5  6 7  8  9  10 11 12 13 14 15 (ii) To display the following pattern I I C I C S I C S E For an incorrect option, an appropriate error message should be displayed. SOURCE CODE import java.io.*; class ICSE2016_Ques5_Pattern {     public static void main(String args[])throws IOException     {         BufferedReader br=new BufferedReader(new InputStreamReader(System.in));         System.out.println("Press 1 to print Floyd's triangle");         System.out.println("Press 2 to print second pattern");         int n=Integer.parseInt(br.readLine());         switch(n)         {             case 1:             System.out.print("Enter a number  :");             int m=Integer.parseInt(br.readLine());             int a=1;             for(int i=1;i<=m;i++)    

[Question 4] ICSE 2016 Computer Application Solved - Book Fair

Image
Question 4. Define a class named  BookFair  with the following description: Instance variables/Data members: String Bname       –           stores the name of the book. double price      –           stores the price of the book. Member Methods: (i)         BookFair()              Default constructor to initialize data members. (ii)        void Input()               To input and store the name and the price of the book. (iii)       void calculate()              To calculate the price after discount. Discount is calculated based on the following criteria. Price Discount Less than or equal to Rs 1000 2% of price More than Rs 1000 and less than or equal to Rs 3000 10% of price More than Rs 3000 15% of price (iv)       void display()              To display the name and price of the book after discount. Write a main method to create an object of the class and call the above member methods. SOURCE CODE import java.io.*; import java.util.*; class Book

[Question 3] ISC 2016 Computer Practical Paper Solved – Words Beginning and Ending with Vowel.

Image
Question 3: Write a program to accept a sentence which may be terminated by either’.’, ‘?’or’!’ only. The words may be separated by more than one blank space and are in UPPER CASE. Perform the following tasks: (a) Find the number of words beginning and ending with a vowel. (b) Place the words which begin and end with a vowel at the beginning, followed by the remaining words as they occur in the sentence. Test your program with the sample data and some random data: Example 1 INPUT: ANAMIKA AND SUSAN ARE NEVER GOING TO QUARREL ANYMORE. OUTPUT: NUMBER OF WORDS BEGINNING AND ENDING WITH A VOWEL= 3 ANAMIKA ARE ANYMORE AND SUSAN NEVER GOING TO QUARREL Example 2 INPUT: YOU MUST AIM TO BE A BETTER PERSON TOMORROW THAN YOU ARE TODAY. OUTPUT: NUMBER OF WORDS BEGINNING AND ENDING WITH A VOWEL= 2 A ARE YOU MUST AIM TO BE BETTER PERSON TOMORROW THAN YOU TODAY Example 3 INPUT: LOOK BEFORE YOU LEAP. OUTPUT: NUMBER OF WORDS BEGINNING AND ENDING WITH A VOWEL= 0 LOOK BEF

[Question 2] ISC 2016 Computer Practical Paper Solved – Sorting Non-Boundary Matrix Elements

Image
Question 2: Write a program to declare a square matrix A[][] of order (M x M) where ‘M’ must be greater than 3 and less than 10. Allow the user to input positive integers into this matrix. Perform the following tasks on the matrix: (a) Sort the non-boundary elements in ascending order using any standard sorting technique and rearrange them in the matrix. (b) Calculate the sum of both the diagonals. (c) Display the original matrix, rearranged matrix and only the diagonal elements of the rearranged matrix with their sum. Example 1 INPUT : M = 4 9   2   1   5   8   13  8   4   15  6   3   11  7   12  23  8   OUTPUT: ORIGINAL MATRIX 9   2   1   5   8   13  8   4   15  6   3   11  7   12  23  8   REARRANGED MATRIX 9   2   1   5   8   3   6   4   15  8   13  11  7   12  23  8   DIAGONAL ELEMENTS 9           5        3   6            8   13      7           8       SUM OF THE DIAGONAL ELEMENTS = 59 S

[Question 1] ISC 2016 Computer Practical Paper Solved – Circular Prime

Image
Question 1: A Circular Prime is a prime number that remains prime under cyclic shifts of its digits. When the leftmost digit is removed and replaced at the end of the remaining string of digits, the generated number is still prime. The process is repeated until the original number is reached again. A number is said to be prime if it has only two factors I and itself. Example: 131 311 113 Hence, 131 is a circular prime. Test your program with the sample data and some random data: Example 1 INPUT : N = 197 OUTPUT: 197 971 719 197 IS A CIRCULAR PRIME Example 2 INPUT : N = 1193 OUTPUT: 1193 1931 9311 3119 1193 IS A CIRCULAR PRIME Example 3 INPUT : N = 29 OUTPUT: 29 92 29 IS NOT A CIRCULAR PRIME SOURCE CODE import java.io.*; class ISC2016_CircularPrime {     boolean isPrime(int n)     {         int c=0;         for(int i=2;i<=n;i++)         {             if(n%i==0)                 c++;         }         if(c==1)    

Program to replace word.

Image
Write a program to replace any word of a entered string with another word. SOURCE CODE import java.io.*; import java.util.*; public class Replacing_Words  {     public static void main(String args[])     {         Scanner sc=new Scanner(System.in);         System.out.print("Enter a String     :");         String str=sc.nextLine();         System.out.print("Enter a word from the same string you have entered :");         String s1=sc.next();         System.out.print("Enter another word :");         String s2=sc.next();         System.out.println("\nAfter replacing all "+s1+" with "+s2+" OUTPUT will be");         System.out.println(str.replace(s1,s2));     } }   OUTPUT If you have any question then leave a comment below I will do my best to answer that question.

Converting each alphabet of a string into its opposite case.

Image
Write a program to input a string. Convert each alphabet into its opposite case. Print original and new string.                SOURCE CODE                          import java.io.*; import java.util.*; public class Conversion {     public static void main(String args[])     {         Scanner sc=new Scanner(System.in);         System.out.print("Enter a String    :");         String str=sc.nextLine();         String st="";         System.out.println("\nOUTPUT");         System.out.println("Original String "+str);                 for(int i=0;i<str.length();i++)         {             char ch=str.charAt(i);             if(Character.isUpperCase(ch))             {                 st=st+Character.toLowerCase(ch);             }             else if(Character.isLowerCase(ch))             {                 st=st+Character.toUpperCase(ch);             }             else             {      

[Question 3] ISC 2017 Computer Practical Paper Solved – Caesar Cipher.

Image
Question 3: Caesar Cipher  is an encryption technique which is implemented as ROT13 (‘rotate by 13 places’). It is a simple letter substitution cipher that replaces a letter with the letter 13 places after it in the alphabets, with the other characters remaining unchanged. Write a program to accept a plain text of length L, where L must be greater than 3 and less than 100. Encrypt the text if valid as per the Caesar Cipher. Test your program with the sample data and some random data: Example 1 INPUT :  Hello! How are you? OUTPUT :  The cipher text is: Uryyb? Ubj ner lbh? Example 2 INPUT :  Encryption helps to secure data. OUTPUT :  The cipher text is: Rapelcgvba urycf gb frpher qngn. Example 3 INPUT :  You OUTPUT :  INVALID LENGTH SOURCE CODE    import java.io.*; import java.util.*; public class ISC2017_CaesarCipher {     public static void main(String args[])     {         Scanner sc=new Scanner(System.in);         System.out.pri

[Question 2] ISC 2017 Computer Practical Paper Solved – Quiz Result

Image
Question: The result of a quiz competition is to be prepared as follows: The quiz has five questions with four multiple choices (A, B, C, D), with each question carrying 1 mark for the correct answer. Design a program to accept the number of participants N such that N must be greater than 3 and less than 11. Create a double dimensional array of size (Nx5) to store the answers of each participant row-wise. Calculate the marks for each participant by matching the correct answer stored in a single dimensional array of size 5. Display the scores for each participant and also the participant(s) having the highest score. Example: If the value of N = 4, then the array would be: Note: Array entries are line fed (i.e. one entry per line) Test your program with the sample data and some random data: Example 1 INPUT :  N = 5 Participant 1 D A B C C Participant 2 A A D C B Participant 3 B A C D B Participant 4 D A D C B Participant 5 B C A D D Key: B C D A A OUTPUT : S

[Question 1] ISC 2017 Computer Practical Paper Solved – Box Packing

Image
Question: A company manufactures packing cartons in four sizes, i.e. cartons to accommodate 6 boxes, 12 boxes, 24 boxes and 48 boxes. Design a program to accept the number of boxes to be packed (N) by the user (maximum up to 1000 boxes) and display the break-up of the cartons used in descending order of capacity (i.e. preference should be given to the highest capacity available, and if boxes left are less than 6, an extra carton of capacity 6 should be used.) Test your program with the sample data and some random data: Example 1 INPUT :  N = 726 OUTPUT : 48 x 15 = 720 6 x 1 = 6 Remaining boxes = 0 Total number of boxes = 726 Total number of cartons = 16 Example 2 INPUT :  N = 140 OUTPUT : 48 X 2 = 96 24 x 1 = 24 12 x 1 = 12 6 x 1 = 6 Remaining boxes 2 x 1 = 2 Total number of boxes = 140 Total number of cartons = 6 Example 3 INPUT :  N = 4296 OUTPUT :  INVALID LENGTH SOURCE CODE import java.io.*; import java.util.*; public class  ISC201

Selection Sort.

Image
Program of Selection Sort. Selection sort is a simple sorting algorithm. This sorting algorithm is an in-place comparison-based algorithm in which the list is divided into two parts, the sorted part at the left end and the unsorted part at the right end. Initially, the sorted part is empty and the unsorted part is the entire list. SOURCE CODE import java.io.*; import java.util.*; public class Selection {     public static void main(String args[])throws IOException     {         int small,place;         Scanner sc=new Scanner(System.in);         System.out.println("Enter the limit of number");         int a=sc.nextInt();         int ar[]=new int [a];         for(int i=0;i<a;i++)         {             System.out.print("Input a No.");             ar[i]=sc.nextInt();         }         System.out.println("Array element before sorting are");         for(int i=0;i<a;i++)         {             System.o