Skip to main content

Posts

Showing posts with the label ICSE

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

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

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