Java Bit

Java Bit

Complete the Solver constructor so that a call to solveAll return a list with 2 values including the square root and the inverse of the integer passed as parameter.

public interface MathFunction { double calculate(double x); }

public class Solver {

private List<MathFunction> functionList;

public Solver() { // Complete here

}

public List<Double> solveAll(double x) { List<Double> result = new ArrayList<Double>();

for (MathFunction function : this.functionList) { 
    result.add(new Double(function.calculate(x))); 
} 

return result;

} }

View Answers

June 8, 2012 at 3:26 PM

The given code accept a given value of double type and determine the square root of that number. Moreover, it also find the inverse of the given number. Both results will get store into the list.

import java.util.*;

public class Solver {
public Solver() {

List<Double> list=solveAll(25);
for(int i=0;i<list.size();i++){
System.out.println(list.get(i));
}
} 

public  List<Double> solveAll(double x) { 
    List<Double> result = new ArrayList<Double>(); 

    result.add(new Double(Math.sqrt(x)));
    double inverse=(double)1/x;
    result.add(new Double(inverse));

    return result; 
}
public static void main(String[]args){
    new Solver();
}

}

Ads









Related Tutorials/Questions & Answers:
java bit
java bit  what is java bit
Java Bit
Java Bit  Complete the Solver constructor so that a call to solveAll return a list with 2 values including the square root and the inverse of the integer passed as parameter. public interface MathFunction { double calculate
Advertisements
java 9 32 bit download
java 9 32 bit download  Hi, I am trying to install JDK..., and then contact software publisher. What is this issue? How o get get Java 9 32 Bit..., 32 bit installer is not available. I you have 32 bit operating system you won't
How to ensure the same output by java code on 32 bit m/c and 64 bit m/c
How to ensure the same output by java code on 32 bit m/c and 64 bit m/c  How to ensure the same output by java code on 32 bit m/c and 64 bit m/c
Standalone Product should support 64 bit java.
Standalone Product should support 64 bit java.  I am working... and make it suitable for 64 bit java. Can you please answere me what I have to do. When we deliver our product we bundle jdk 32 bit with it. So now what jdk we
what is bit
what is bit  what is bit
Bitwise and Bit Shift Operators
Bitwise and Bit Shift Operators       In Java the bitwise and bit shift operators are used to manipulate the contents of variables at a bit level according to binary format
ModuleNotFoundError: No module named 'bit'
ModuleNotFoundError: No module named 'bit'  Hi, My Python program is throwing following error: ModuleNotFoundError: No module named 'bit' How to remove the ModuleNotFoundError: No module named 'bit' error
Read Bit values
Read Bit values  how to read bit values in the program Please give suggestion, which is useful in Simplified DES Algorithm
64 bit dll
64 bit dll  how can we use 32 bit dll in 64 bit OS..i getting the error Exception in thread "main" java.lang.UnsatisfiedLinkError: no dsn in java.libra y.path at java.lang.ClassLoader.loadLibrary(Unknown Source
ModuleNotFoundError: No module named 'bit_array'
ModuleNotFoundError: No module named 'bit_array'  Hi, My Python... 'bit_array' How to remove the ModuleNotFoundError: No module named 'bit... have to install padas library. You can install bit_array python with following
ModuleNotFoundError: No module named 'bit-bind'
ModuleNotFoundError: No module named 'bit-bind'  Hi, My Python program is throwing following error: ModuleNotFoundError: No module named 'bit-bind' How to remove the ModuleNotFoundError: No module named 'bit-bind
ModuleNotFoundError: No module named 'bit-notify'
ModuleNotFoundError: No module named 'bit-notify'  Hi, My Python... 'bit-notify' How to remove the ModuleNotFoundError: No module named 'bit... have to install padas library. You can install bit-notify python
ModuleNotFoundError: No module named 'bit_wise'
ModuleNotFoundError: No module named 'bit_wise'  Hi, My Python program is throwing following error: ModuleNotFoundError: No module named 'bit_wise' How to remove the ModuleNotFoundError: No module named 'bit_wise
ModuleNotFoundError: No module named 'A-Bit-Racey'
ModuleNotFoundError: No module named 'A-Bit-Racey'  Hi, My Python... 'A-Bit-Racey' How to remove the ModuleNotFoundError: No module named 'A-Bit-Racey' error? Thanks   Hi, In your python environment
ModuleNotFoundError: No module named 'bit_array'
ModuleNotFoundError: No module named 'bit_array'  Hi, My Python... 'bit_array' How to remove the ModuleNotFoundError: No module named 'bit... have to install padas library. You can install bit_array python with following
ModuleNotFoundError: No module named 'bit_array'
ModuleNotFoundError: No module named 'bit_array'  Hi, My Python... 'bit_array' How to remove the ModuleNotFoundError: No module named 'bit... have to install padas library. You can install bit_array python with following
ModuleNotFoundError: No module named 'bit-cryptocompare'
ModuleNotFoundError: No module named 'bit-cryptocompare'  Hi, My... named 'bit-cryptocompare' How to remove the ModuleNotFoundError: No module named 'bit-cryptocompare' error? Thanks   Hi, In your
ModuleNotFoundError: No module named 'bit-field'
ModuleNotFoundError: No module named 'bit-field'  Hi, My Python... 'bit-field' How to remove the ModuleNotFoundError: No module named 'bit... have to install padas library. You can install bit-field python with following
ModuleNotFoundError: No module named 'bit-vector'
ModuleNotFoundError: No module named 'bit-vector'  Hi, My Python... 'bit-vector' How to remove the ModuleNotFoundError: No module named 'bit... have to install padas library. You can install bit-vector python
ModuleNotFoundError: No module named 'logparser-bit'
ModuleNotFoundError: No module named 'logparser-bit'  Hi, My... 'logparser-bit' How to remove the ModuleNotFoundError: No module named 'logparser-bit' error? Thanks   Hi, In your python
MySQL BIT
MySQL BIT This example illustrates how to create the table with BIT type field. In this example we create a table with BIT type field and insert some... t (b BIT(8));   Query  
ModuleNotFoundError: No module named 'BIT-Online-Code-Helper'
ModuleNotFoundError: No module named 'BIT-Online-Code-Helper'  Hi...: No module named 'BIT-Online-Code-Helper' How to remove the ModuleNotFoundError: No module named 'BIT-Online-Code-Helper' error? Thanks   Hi
ModuleNotFoundError: No module named 'eight-bit-computer'
ModuleNotFoundError: No module named 'eight-bit-computer'  Hi, My... named 'eight-bit-computer' How to remove the ModuleNotFoundError: No module named 'eight-bit-computer' error? Thanks   Hi, In your
ModuleNotFoundError: No module named 'django-bit-category'
ModuleNotFoundError: No module named 'django-bit-category'  Hi, My... named 'django-bit-category' How to remove the ModuleNotFoundError: No module named 'django-bit-category' error? Thanks   Hi
ModuleNotFoundError: No module named 'eight-bit-computer'
ModuleNotFoundError: No module named 'eight-bit-computer'  Hi, My... named 'eight-bit-computer' How to remove the ModuleNotFoundError: No module named 'eight-bit-computer' error? Thanks   Hi, In your
ModuleNotFoundError: No module named 'gym-bit-flip'
ModuleNotFoundError: No module named 'gym-bit-flip'  Hi, My Python... 'gym-bit-flip' How to remove the ModuleNotFoundError: No module named 'gym-bit-flip' error? Thanks   Hi, In your python
download eclipse helios for windows 7 64 bit
download eclipse helios for windows 7 64 bit  How to download eclipse helios for windows 7 64 bit? Thanks
Java bitwise OR "|" operator
Java bitwise OR "|" operator In this section you will learn about how to use" |" operator in java. Java provides six types of operators...; operator work on bit and perform bit by bit operation. Example: Let us
SQL bit
MySQL BIT Type
MySQL BIT Type This example illustrates how many types of BIT operator are used in the MySQL query and how to used it in the query. In this example we implement the operator OR( | ), AND( & ), XOR( ^ ), Left Shift(<<

Ads