How to transform this pascal code into java code!

I want to transform this pascal code into java code . Please tel me how to do it because I really don't know how to do it!
Thanks!
{CALCULATE HOHN-LONDON FACTORS}
var kk:tab4;
PROCEDURE INTENS(var kk:tab4);
begin
for n:=0 to nr+2 do
begin
kk^[1,n]:=sqrt(lup*lup*yg*(yg-4)+4*sqr(n+1)) +lup*(yg-2);
kk^[2,n]:= sqrt(lup*lup*yg*(yg-4)+4*sqr(n+1))-lup*(yg-2);
kk^[3,n]:=0.5*(kk^[1,n]*kk^[1,n]+4*(sqr(n+1)-lup*lup));
kk^[4,n]:= 0.5*(kk^[2,n]*kk^[2,n]+4*(sqr(n+1)-lup*lup));
kk^[5,n]:= sqrt(ldown*ldown*yd*(yd-4)+4*sqr(n+1)) +ldown*(yd-2);
end;
end;
BEGIN
new (kk);
intens(kk);
writeln(f2,' ','N ','V','branch ','H-L');
for n:=1 to np do
begin
fp1[n,v]:=(n-ldown)*(n+ldown+1)*sqr(kk^[2,n-1]*kk^[6,n]+4*(n+ldown)*(n-ldown+1));
fp1[n,v]:=fp1[n,v]/(4*(n+0.5)*kk^[4,n-1]*kk^[8,n]) ;
writeln(f2,' ',n,' ',v,' fp1 ',fp1[n,v]:10:2);
end;
for n:=1 to nq do
begin
fq1[n,v]:=sqr(kk^[2,n]*kk^[6,n]*(ldown+0.5)+4*(n-ldown+1)*(n+ldown+1)*(ldown-0.5)) ;
fq1[n,v]:=fq1[n,v]/(2*(n+0.5)*kk^[4,n]*kk^[8,n]*(n+1.5));
fq1[n,v]:=fq1[n,v]*(n+1);
writeln(f2,' ',n,' ',v,' fq1 ',fq1[n,v]:10:2);
end;
for n:=1 to nr do
begin
fr1[n,v]:=sqr(kk^[2,n+1]*kk^[6,n]+4*(n-ldown+2)*(n+ldown+1));
fr1[n,v]:=fr1[n,v]/(4*kk^[4,n+1]*kk^[8,n]*(n+1.5));
fr1[n,v]:=fr1[n,v]*(n-ldown+1)*(n+ldown+2) ;
writeln(f2,' ',n,' ',v,' fr1 ',fr1[n,v]:10:2);
end;

Basically it looks like this:
public class KK{
     private your_type[][] kk = new your_type[length][length];
     private void intens(your_type[] kk){
          for(int n= 0; n<nr+2; n++){
               kk[1][n] = Math.sqrt(lup*lup*yg*(yg-4)+4*Math.pow((n+1), 2)) +lup*(yg-2);
               kk[2][n] = Math.sqrt(lup*lup*yg*(yg-4)+4*Math.pow((n+1), 2))-lup*(yg-2);
               kk[3][n] = 0.5*(kk[1][n]*kk[1][n]+4*(Math.pow((n+1), 2)-lup*lup));
               kk[4][n] = 0.5*(kk[2][n]*kk[2][n]+4*(Math.pow((n+1), 2)-lup*lup));
               kk[5][n] = Math.sqrt(ldown*ldown*yd*(yd-4)+4*Math.pow((n+1), 2)) +ldown*(yd-2);
     public static void main(String args[]){
          KK k = new KK();
          k.intens(kk);
          System.out.println(f2  + ' ' + 'N ' + 'V' + 'branch ' + 'H-L');
          for(int n=1; n < np; n++){
               fp1[n][v] = (n-ldown)*(n+ldown+1)*Math.pow((kk[2][n-1]*kk[6][n]+4*(n+ldown)*(n-ldown+1)), 2);
               fp1[n][v] = fp1[n][v]/(4*(n+0.5)*kk[4][n-1]*kk[8][n]) ;
               System.out.println(f2 + ' ' + n + ' ' + v + ' fp1 ' + fp1[n][v]:10:2);
          for(int n=1; n< nq;n++){
               fq1[n][v] = Math.pow((kk[2][n]*kk[6][n]*(ldown+0.5)+4*(n-ldown+1)*(n+ldown+1)*(ldown-0.5)), 2);
               fq1[n][v] = fq1[n][v]/(2*(n+0.5)*kk[4][n]*kk[8][n]*(n+1.5));
               fq1[n][v] = fq1[n][v]*(n+1);
               System.out.println(f2 + ' ' + n + ' ' + v + ' fq1 ' + fq1[n][v]:10:2);
          for(int n=1; n < nr; n++){
               fr1[n][v] = Math.pow((kk[2][n+1]*kk[6][n]+4*(n-ldown+2)*(n+ldown+1)), 2);
               fr1[n][v] = fr1[n][v]/(4*kk[4][n+1]*kk[8][n]*(n+1.5));
               fr1[n][v] = fr1[n][v]*(n-ldown+1)*(n+ldown+2) ;
               System.out.println(f2 + ' ' + n + ' ' + v + ' fr1 ' + fr1[n][v]:10:2); //fr1[n][v]:10:2 --> Here you must use the BigDecimal class
}I'm not very sure because my pascal knowledge is extremely "dated".
What about the converter I told you about?

Similar Messages

  • Converting CPP code into JAVA Code

    i have made a cpp file that is running fine... is ther a tool which can convert that cpp file into java file easily?

    No

  • How to read ABAP return parameter into java code

    Hi all,
    How JAVA environment can trap an error returned from abap code?
    E.g.:
    From a BAPI wrapper written like this:
    "function zpm_gi_create .
    ""Interfaccia locale:
    *"  IMPORTING
    *"     VALUE(ZBAPIGOODSMVT) TYPE  ZBAPIGOODSMVT
    *"  EXPORTING
    *"     VALUE(RETURN) TYPE  BAPIRET2
    *"     VALUE(PO_NUMBER_ES) TYPE  ZBAPIEKKO-PO_NUMBER
    *"  TABLES
    *"      GOODSMVT_ITEM STRUCTURE  ZGOODSMVT_ITEM
      data: goodsmvt_header type bapi2017_gm_head_01,
            return2         type bapiret2 occurs 0 with header line,
      call function 'BAPI_GOODSMVT_CREATE'
        exporting
          goodsmvt_header             = goodsmvt_header
          goodsmvt_code               = zbapigoodsmvt-gm_code
          testrun                     = 'X'
    importing
      GOODSMVT_HEADRET   GM         =
        materialdocument              = matdoc
        matdocumentyear               = matyear
    tables
        goodsmvt_item                 = gm_item
      GOODSMVT_SERIALNUMBER       =
          return                      = return2.
    Our return (for istance is):
    "EBM                  312The (internal) unit xx has not been maintained in
    the unit table"
    How JAVA environment can trap this error or interpret the BAPIRET2 structure?
    Is there something to do in the corresponding syncBO?
    regards,
    eliana

    Hi elina ,
    these topic is already discussed in forum.
    Jo has replied to this doubt in these links.
    Re: Return messages in SyncBo
    Can't see RETURN parameter in SyncBO
    Return messages in SyncBo
    just note this..
    have to change like this , when u follow the help.
    if (messageReply.getType() == MessageReplyType.SYNC_BEGIN) {
              if (messageReply.getType() == MessageReplyType.SYNC_END) {
                Regards
                  Kishor Gopinathan

  • How to use .properties files in Webdynpro Java code?

    Hi all,
      I want to use a logon.properties file when I initial a JCO connection pool in my webdynpro DC (JCO.addClientPool()),but  I found when I deployed this DC to the server, it always giv e me an FileNotFoundException. So I donot know how to deploy a .properties file to the server and how to access this file in my Java code?
    Thans and Best regards
    Deyang

    Hi,
    1) put .properties file to your packege under src\packages folder (src\packages\com\sdn\properties\jco.properties)
    2) load property:
         final InputStream is = getClass().getClassLoader().getResourceAsStream("com/sdn/properties/jco.properties");
         final Properties properties = new Properties();
         try
              properties.load(is);
         catch(Exception e)
              wdComponentAPI.getMessageManager().reportException(new WDNonFatalException(e), false);
    Regatds Maxim R.

  • How to convert Vb code into java?

    Hi,
    I want to know how to make conversion a visual basic source code into java. The conversion could be (1:1) scale.
    Is there any compilers making the live easier (solving this problem) ?
    Thank you all.
    Abu_ramla

    Use the JNI. VB doesent actually do anything on its own. Its just a series of calls on COM objects to performs all its work. You can call these same COM objects using the Java Native Interface or JNI. You wont have access to things designed in VB though like forms, you will have to redesign those.
    This will take extensive knowledge of COM, VB, Java, and JNI. It will take you about 1 year to get up to speed. I would say to not do this.

  • Please help me transform this C++ code to java code....

    guys...please help me transform this C++ code to java code....please try to explain the code..thanks
    [program]
    #include <stdio.h>
    #define ALIVE 1
    #define DEAD 0
    #define SZ 33
    int stschk (int ,int );
    main()
    int s[SZ][SZ], i, j;
    for (i=0; i<sz; i++ ) s[0] = DEAD;
    for (j=0; j<sz; j++ ) s[0][j] = DEAD;
    s[0][1] = ALIVE;
    for (i=0; i<sz-1; i++) {
    for ( j=1;j<sz;j++ ) {
    s[i][j] = stschk(s[i][j-1],s[i+1][j];
    if(s[i][j-1]==ALIVE) printf("*");
    else printf(" ");
    printf("\n");
    int stschk(int s1,int s2)
    if(((s1==DEAD)&&(s2==ALIVE))||
    ((s1==ALIVE)&&(s2==DEAD))) return ALIVE;
    else return DEAD;

    Being picky, that's not C++, that's C. Standard headers in C++ dont' have .h after them, loop variables are scoped with the for, you use constants rather than #defines, etc..
    C and C++ both don't initialise arrays by default; you'd have to write an initialiser to get it to zero out the array:
        int s[sz][sz] = {};gcc will insert a call to memset to zero the array.
    If the author was assuming that the array was zeroed out, there would be no point zeroing the first row and column.
    The code reads values which haven't been initialised. If you mark such values explicitly undefined, and change the program to report an error when undefined, then you get several cases where the program makes such report.
    So either it' s a primitive random number generator (some random number generators use uninitialised memory as a source of randomness), or it's buggy, or it's processing undefined data and throwing away the result. Either way, it cannot be directly be ported to Java if the undefined values (which are limited to a small area of the ouput) are significant.

  • How to create a oracle database by java code?

    how to create a oracle database by java code?
    please give some ways then that way's code

    I'm not sure what you mean with "database". Do you mean an Oracle instance or an Oracle user/schema (probably the latter, because that's the equivalent to a MS SQL Database).
    Creating an instance is definitely not possible from within Java. To create a new user this should be possible, as this can be done with SQL:
    GRANT connect,resource TO <newuser> IDENTIFIED BY <password>;
    I'm always cautious with questions like this. In 90% of the cases there is something wrong with the initial design. Creating a database shouldn't be something the application is doing.
    Thomas

  • [ETL]How to transform a Source model into an arbitrary number of target models ?

    Hi all,
    I need to know how to transform a source model into an arbitrary number of target models which conforms to different target metamodels using ETL ? Is there any examples that can help me ?
    Thank you
    Mana

    Hi Antonio,
    Actully I mean the number of metamodels are known.For example, assume that there are two known metamodels in the target side, the first one is the target metamodel, and the second one is the trace metamodel .
    I would like to see an example of ETL transformation that run on a source model and generate the target model and the trace model as well. This statement is part of the chapter 5 of the ebook which says "it is often essential to be able to access/update additional models during a transformation (such as trace or configuration models). Building on the facilities provided by EMC and EOL, ETL enables specification of transformations that can transform an arbitrary number of source models into an arbitrary number of target models."
    could you please explain this more for me or provide me with an example.
    Thank you
    Mana

  • How to read XI Data type in Java code and populate as array list, using UDF

    Hi,
    How to read XI Data type in Java code and populate as array list, using UDF?
    Is there any API using which  the XI data types can be read?
    Kindly reply.
    Richa

    Input Structure:
    <?xml version="1.0" encoding="UTF-8"?>
    <ns0:CustomerCreateResp xmlns:ns0="urn:bp:xi:up:re:cust_mdm:cmdm:pr5:100">
       <CUSTOMER>
          <item>
             <CUSTOMERNO/>
             <MDMCUSTOMER/>
             <CREATE_DATE/>
             <RETURN>
                <TYPE/>
                <MESSAGE/>
             </RETURN>
             <PT_CONTPART_RETURN>
                <item>
                   <MDM_CONTACT/>
                   <CONTACT/>
                </item>
             </PT_CONTPART_RETURN>
             <PARTNERS>
                <item>
                   <CUSTOMERNO/>
                   <PARTNER_FUNCTION/>
                   <PARTNER_NUMBER/>
                   <DEFAULT_PARTNER/>
                </item>
             </PARTNERS>
          </item>
       </CUSTOMER>
    </ns0:CustomerCreateResp>
    Output structure
    (Sample output structure.This actually needs to be mapped and generated using UDF)
    <?xml version="1.0" encoding="UTF-8"?>
    <ns1:updateCustomer xmlns:ns1="urn:xiSericeVi"><ns1:customer><ns2:ArrayList xmlns:ns2="java:sap/standard">[]</ns2:ArrayList></ns1:customer><ns1:name>2344566</ns1:name></ns1:updateCustomer>

  • How to find the  System Dbtype in java code

    How to find the System Dbtype in java code
    I need various Db connection my project (oracle, sq l,sybase,db2),So How to find the System Dbtype in java code

    Welcome to the Forums.
    Please go through the FAQ of the Forum.
    You has posted your query in the wrong Forum, this one is dedicated to Oracle Forms.
    Please try {forum:id=1050}.
    Regards,

  • Pythagors into java-code (i got the idea, i think,  but need it simplified)

    Goodday all :),
    I have been trying to turn the forumula | a^2 + b^2 = c^2 | into java code.
    To clear it up a little more;
    1. Define unknown variable
    2. Define values of other two variables
    3. Program calculates
    x1. unkown variable is 'a'
    x2. b = 20 , c = 40
    x3. a = [(40^2) - (20^2)] ^0.5 (sorry couldnt figure out superscript)
    What i was thinking as a concept;
    1. Java asks for uknown value -> user defines as 'a' , 'b' or 'c'.
    2. Java If else statement
    2.1 if 'd' -> java asks again
    2.2 else 'e' --> java asks again etc (if else statemenst from d - z)
    import java.io.*;
    public class example {
         public static void main(String[] args) {
              System.out.println("define uknown value");
              BufferedReader reader = new BufferedReader(new InputStreamReader(System.in));
              boolean running = true;
              while(running) {
                        String line = reader.readLine();
                        if (line.startsWith("d")) {
                             System.out.println("wrong input, define unknown value");
                             running = true;
                             } else      if (line.startsWith("e")) {
                             System.out.println("wrong input, define unknown value");
                             running = true;
                             } else      if (line.startsWith("f")) {
                             System.out.println("wrong input, define unknown value");
                             running = true;
                             } else      if (line.startsWith("g")) {
                             System.out.println("wrong input, define unknown value");
                             running = true;and furter i was thinking;
    If a, b or c is pressed it will ask for the values of the other two
    and it will be such a code as above, repeating itself;
                        String line = reader.readLine();
                        if (line.startsWith("a")) {
                             System.out.println("please define b");
                             running = true;
                             if (line.startsWith("1")) {
                             int x = 1;
                             System.out.println("b=1");
                             running = true;
                             } else      if (line.startsWith("2")) {
                             int x = 2;
                             System.out.println("b=2");
                             running = true;
                             } else      if (line.startsWith("3")) {
                             int x = 3;
                             System.out.println("b=3");
                             running = true;and so on till, lets say 1000?
    Now my question is;
    Is this the right way to make this program?
    I would have like a .java file of severel megebytes if i wanted the values to get up to 10000 or something >.<

    Aargh! No. This code snippet might be of help.
    try {
       int x = Integer.parseInt("42");
       System.out.println("X = " + x);
    } catch( NumberFormatException e ) {
       System.err.println("Not a number: " + e);
       e.printStackTrace();
    }You would probably also find it useful to read about "regular expressions" if you always expect the formula to have exactly the same form.

  • How to get af:commandbutton id in java code when it is triggered?

    Hi All
    In my application's homepage, I am using 2 af:commandbuttons and each using action attribute to call a method. Both are calling the same method, and based on its id, it should perform different operations. Could anyone please tell me how to get command buttons id in java code, when it is triggered.
    Regards
    Venkat

    Venkat,
    why not call different methods from each button?
    public String actionButton1()
    return doAction("button1");
    public String actionButton2()
    return doAction("button2");
    public String doAction(String aBuuton)
    if ("button1".equalsIgnoreCase(aButton))
    // do work for button 1
    return "abc";
    }else {
    // do work for button 2
    return "abc";
    }Now you user actionbutton1 for the first button and actionButton2 for the second.
    Or you directly implement two different methods in the bean and call each one directly from the button.
    Timo

  • How to call a .bat file from java code?

    How to call a .bat file from java code? and how can i pass parameters to that .bat file?
    Thanks in advance

    thanks for ur reply
    but still i am getting the same error.
    I am trying to run a .bat file of together tool, my code looks like below
    import java.lang.Runtime;
    import java.lang.Process;
    import java.io.File;
    class SysCall{
         public static void main(String args[]){
              String cmd="D://Borland//Together6.2//bin//Together.bat -script:com.togethersoft.modules.qa.QA -metrics out:D://MySamples//Metrics// -fmt:html D://Borland//Together6.2//samples//java//CashSales//CashSales.tpr";
              //String path="D://Borland//Together6.2//bin//Together.bat ";
              Runtime r= Runtime.getRuntime(); //Declare the system call
              try{
                   System.out.println("Before batch is called");
                   Process p=r.exec(cmd);
                   System.out.println(" Exit value =" + p.exitValue());
                   System.out.println("After batch is called");
              /*can produce errors which must be caught*/
              catch(Exception e) {
                   e.printStackTrace();
                   System.out.println (e.toString());
    I am getting the below exception
    Before batch is called
    java.lang.IllegalThreadStateException: process has not exited
    at java.lang.Win32Process.exitValue(Native Method)
    at SysCall.main(SysCall.java:17)
    java.lang.IllegalThreadStateException: process has not exited

  • The volume keys on my Logitech K760 wireless keyboard do not work with my 2.3 GHz, Intel Core i5 Mac mini which runs Mac OS X 10.7.4. Anyone know how to correct this without having to re-code firmware?

    My first post to the Apple Support Community so it looks like all I wanted to know is covered in the title. The research I have done led me to solutions that I am not comfortable trying for fear of irreparably damaging my keyboard and/or Mac mini. Does anyone have a simpler solution? Please? Hellooooo?
    Just in case the title is too long to show, I have re-pasted here:
    The volume keys on my Logitech K760 wireless keyboard do not work with my 2.3 GHz, Intel Core i5 Mac mini which runs Mac OS X 10.7.4. Anyone know how to correct this without having to re-code firmware?

    BDAqua wrote:
    Hello & welcome to the Forums!
    I think Spark cured this for another person and the same problem...
    http://www.shadowlab.org/Software/spark.php
    http://scripts.sil.org/cms/scripts/page.php?site_id=nrsi&id=ukelele
    http://doublecommand.sourceforge.net/
    Thank you for the response. Unfortunately, I could not figure out how to work the above applications. I thought that i had managed to assign the appropriate function keys in Spark to their volume counterparts, but it had no effect. Below is a screen shot. Do you see anything amiss?

  • How to call web-service using only java code

    Hello, how to call web-service using only java code. I can call it from BPM process or Web Dynpro Java Application, but if I need to call it from ejb component?

    I'm found answer:
    Java and SAP Portal blog: How to call web service from java code example

Maybe you are looking for