Search for more details......

How to solve formulas in java

Solve you formulas using java

Java is a programming language that is the most popular programming language for various fields.
 And also there are many framework built by java team.

Java SE (Standalone Edition)
Java EE (Enterprise Edition)
Java ME (Mobile Edition)

are the different of java jdk.

You can solve your any formula using Java SE.

Example
Lets solve a formula P=I x V
In this formula used to calculate power consumption of electrical devices.

P-Power
I-Ampier
V-Volt

For as an example, let I=2 and V=230 

solve the value of P

P=I xV


In java we have to make variable for store data that want to solve formula.


public class Solver{

    public static void main(String args[]){

         double I=2;           //Let I=2
         double V=230;     //V=230
         double P=0           //P=0 , Because of we don't know the value of P yet(we have to calculate it).
                                           //But we must initialize very variables in java before used.
                                           // That's because we assign 0 to P

             P=I * V                //This is the formula we have to solve. * is the multiplication operator.

               //Now we have solve the formula, you have the solved value in the variable P.

                //If you want to print it out in to the console

              System.out.println("Calculated power is:"+ P);

               //Compile and run the code, you can see the value of P(Power of the formula).

               //You can solve any formula like that very easily in java.


 


      }


}

No comments:

Post a Comment