Skip to main content

Posts

Showing posts with the label ISC

File Handling in Java ISC Class 11

Binary File For Creating/Storing Information into the file FileOutputStream fout = new FileOutputStream(new File("filename",true)); //true for append DataOutputStream ffout = new DataOutputStream(fout); Functions to store data: Integers -  ffout.writeInt(); Floating -  ffout.writeFloat(); Double   -  ffout.writeDouble(); char     - ffout.writeChar(); String   - ffout.writeUTF(); For reading the file  FileInputStream fin = new FileInputStream(new File("filename")); DataInputStream ffin = new DataInputStream(fin); Functions to read data: Integers -  ffin.readInt(); Floating -  ffin.readFloat(); Double   -  ffin.readDouble(); char   ...

Propositional Logic Notes Class 11 ISC

The concept of proposition means any statement which gives result either true or false. p: "Today is cold day" so p is the propositional constant and the rest is the statement.  There are two types of proposition: 1) Simple: Example is: p: "Today is holiday" q: " Dad is at home" 2)Complex/Compound: When we are combining multiple propositional statements into a single statement using logical connectives that is known as compound proposition. p and q: " Today is holiday and Dad is at home" over here"and" is the logical connective. There a multiple logical connectives such as: 1)Conjunction (and)  . / ^ 2)Disjunction (or) +/v 3) Negation (not) ~  4) Implication(if ....then) -> 5) Equivalence/Biconditional (if and only if) <=> or <-> 1) Conjunction   ------------------------ p: "Today is holiday" q: " Dad is at home" p^q: "Today is holiday and Dad is at home" Truth Table p.        q.    ...

ISC 2025 Theory Question: Colsum check

Design a class Colsum to check if the sum of elements in each corresponding column of two matrices is equal or not. Assume that the two matrices have the same dimensions. Example: INPUT: 2 3 1 7 5 6 1 4 2 MATRIX A 7 4 2 1 3 1 2 5 6 MATRIX B OUTPUT: Sum of corresponding columns is equal. The details of the members of the class are given below: Class name: Colsum Data members/instance variables: mat[][]: to store the integer array elements m: to store the number of rows n: to store the number of columns Member functions/methods: Colsum(int mm, int nn): parameterized constructor to initialize the data members m = mm and n = nn void readArray(): to accept the elements into the array boolean check(Colsum A, Colsum B): to check if the sum of elements in each column of the objects A and B is equal and return true, otherwise return false void print(): to display the array elements Specify the class Colsum giving details of the constructor, void readArray(), boolean check(Colsum, Colsum), and v...

ISC 2025 Theory Question Pernicious number

A class Perni has been defined to accept a positive integer in binary number system from the user and display if it is a Pernicious number or not. A pernicious number is a binary number that has minimum of two digits and has prime number of 1s in it. Examples: 101 is a pernicious number as the number of 1s in 101 = 2 and 2 is prime number. 10110 is a pernicious number as the number of 1s in 10110 = 3 and 3 is prime number. 1111 is NOT a pernicious number as the number of 1s in 1111 = 4 and 4 is NOT a prime number. The details of the members of the class are given below: Class name: Perni Data members/instance variables: num: to store a binary number Methods/Member functions: Perni(): constructor to initialize the data member with 0 void accept(): to accept a binary number (containing 0s and 1s only) int countOne(int k): to count and return the number of 1s in ‘k’ using recursive technique void check(): to check whether the given number is a pernicious number by invoking the function co...

ISC Program: Highest and Lowest ASCII code in lowercase and uppercase characters

 Write a program in Java to enter the string. Count and display: The character with lowest ASCII code in lower case The character with highest ASCII code in lower case The character with lowest ASCII code in upper case The character with highest ASCII code in upper case Sample Output: The character with lowest ASCII code in lower case: a The character with highest ASCII code in lower case: y The character with lowest ASCII code in upper case: E The character with highest ASCII code in upper case: P Solution: import ISjava.util.Scanner; class lowhighascii {     public static void main(){         Scanner sc=new Scanner(System.in);         System.out.println("Enter a sentence:");         String s = sc.nextLine();         int p=0,q=999,r=0,t=999;         for(int i=0;i<s.length();i++)         {             char ch = s.charAt(i...

ISC Program: Write a program in Java to accept a string and display the new string after reversing the characters of each word.

Write a program in Java to accept a string and display the new string after reversing the characters of each word. Sample Input: Understanding Computer Science Sample output: gnidnatsrednU retupmoC ecneicS Solution: import java.util.Scanner; class reverseEachWord {     public static void main()     {         Scanner sc=new Scanner(System.in);         System.out.println("Enter a sentence:");         String s=sc.nextLine()+" ";         String w="";         String res=" ";         for(int i=0;i<s.length();i++)         {             char ch = s.charAt(i);             if(ch==' ')             {                 String m="";                 for(int j=w.length()-1;j...

ISC Program: Predict day of the week from date

Algorithm : 1)Take the last two digits of the year. 2)Divide by 4, discarding any fraction. 3)Add the day of the month. 4)Add the month's key value: JFM AMJ JAS OND 144 025 036 146 5)Subtract 1 for January or February of a leap year. 6)For a Gregorian date, add 0 for 1900's, 6 for 2000's, 4 for 1700's, 2 for 1800's; for other years, add or subtract multiples of 400. 7)For a Julian date, add 1 for 1700's, and 1 for every additional century you go back. 8)Add the last two digits of the year. 9)Divide by 7 and take the remainder. Example : Let's take a date: 26/03/2027 Last two digit of the year = 27 Divide by 4 discard fraction = 27/4 = 6.75 = 6 Add day = 6 + 26 = 32 Month key = 4 + 32 = 36 Add year code = 36 + 6 = 42 Now add two digits of the first year = 42 + 27 = 69 Now get the remainder after dividing by 7 = 69%7=6 So 1 is Sunday so 6 is Friday So 27/03/2027 Program : import java.util.Scanner; public class daydate {     public static void main(String[] arg...