Skip to main content

Posts

Math Library All Programs Solved Class 9 Java

[All Math library Programs From APC Class 9] import java.util.Scanner; class Q1{     public static void main(String args[]){         Scanner sc=new Scanner(System.in);         System.out.println("Enter three numbers:");         int a = sc.nextInt();         int b = sc.nextInt();         int c = sc.nextInt();         int g = Math.max(a,Math.max(b,c)); //greatest         int s = Math.min(a,Math.min(b,c)); //smallest         System.out.println("The greatest is:"+g);         System.out.println("The smallest is:"+s);     } } import java.util.Scanner; class Q2{     public static void main(String args[]){         Scanner sc=new Scanner(System.in);         System.out.println("Enter the perpendicular:");         int p = sc.nextInt...
Recent posts

ICSE Class 9 Notes: Inputs in Java

 Inputs in Java Errors: are basically programming problems which we face while solving a problem.  There are different types of errors: 1) Syntax Error or Compile-Time Error: are the errors which immediately detected by the javac compiler during compilation. The common mistakes that causes syntax or compile time errors are: 1) Missing semicolon 2) Misspelling of identifiers and keywords 3) Use of undeclared variables. 4) Incompatible types in assignments or initializations 5) Use of = in place of == operator 6) Missing braces {} in classes and methods. and many more 2) Run Time Error: the error that appears during the run or execution time of a program other than the syntax error is called runtime error. The common mistakes that causes runtime errors are: 1) Dividing a number by zero. 2) Passing a parameter that is not in a valid range or value for method. 3) While entering data during the program execution, entering an integer into a string data type will result in an error. ...

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

Java Mathematical Library Notes

Mathematical Library ---------------------- The math library is present under the package java.lang. Not under the package java.math . 1) Math.sqrt() -> return type is double. It returns the square root of a number. (a) double x = Math.sqrt(4);  => 2.0 (b) double y = Math.sqrt(-4); => NaN (Not a number) (for any negative value the answer is always NaN) 2) Math.cbrt() -> return type is double. It returns the cube root of a number (a) double x = Math.cbrt(8); => 2.0 (b) double y = Math.cbrt(-125); => -5.0 3) Math.pow() -> return type is double  Syntax:  Math.pow(base,exponent) 5 to the power of 3 (here 5 is base and 3 is exponent) (a) double x = Math.pow(5,3); => 125.0 (b) double y = Math.pow(16,1/2); => Math.pow(16,0); => 1.0     here 1/2 is 0 (L<R,/,0 when both are integer) (c) double z = Math.pow(16,1.0/2); => Math.pow(16,0.5) => 4.0 (d) double a = Math.pow(-16,1.0/2); => NaN  (e) double b = Math.pow(64,1.0/3); =...

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

ISC Program : Position deletion in a sentence

  WAP to accept  a sentence which may be terminated by either , ; ? . or !(Any other character may be ignored). The words may be separated by more than one blank space and are in upper case. Perform the following tasks: (i) Accept the sentence and reduce all extra blank spaces between two words to a single blank space. (ii) Accept a word from the user which is a part of the sentence along with its position number and delete the word and display the distance. Example: Input: AS YOU SOW,SO SO YOU REAP. AS YOU SOW,SO SO YOU REAP Word To be deleted : SO Word position in the sentence: 4 Output: AS YOU SOW,SO YOU REAP import java.util.*; public class code {     public static void main( String [] args) {         Scanner sc= new Scanner(System.in);         System.out.println( "Enter a sentence:" );         String m = sc.nextLine();         char ch = m.charAt(m.length()- 1 );   ...