Results 1 to 11 of 11
  1. #1
    eduard is offline Member
    Join Date
    Feb 2011
    Posts
    5
    Rep Power
    0

    Default Plzz help anyone To convert this C++ codes to Java

    #include<dos.h>
    #include<stdlib.h>
    #include<stdio.h>
    #include<iomanip.h>
    #include<iostream.h>
    #include<fstream.h>
    #include<conio.h>
    #include<string.h>
    void line();
    /************************************************** *****************/

    fstream emp_data; ofstream dtr;
    char emp_rec[100],smiled[]=",",*tok;

    int x=1,found=0,countname, n=0,y=0;

    char empcode[10],name[30],level[10],rate[10];
    char code[10];

    char *days[]={"MONDAY","TUESDAY","WEDNESDAY","THURSDAY","FRIDA Y"};
    char date[30],dtrtime[100]="";
    char otin[5],otout[5],ans;

    int holidayhours = 0,totalot = 0 ,othours = 0;


    int tinhr,tinmi,touthr,toutmi;
    double totalhours=0,hoursworked=0,late=0,undertime=0;
    char *tin,*tout,tdelim[]=",";
    double salrate=0,regincome=0,otincome = 0,grossincome = 0;
    /************************************************** *****************/

    int main() ////// From to this Code,,
    {
    clrscr();
    char timein[5],timeout[5];
    emp_data.open("C:\\Payroll\\Employee.txt",ios::in) ;
    if(emp_data.good())
    {
    cout<<"Enter Employee Code: ";
    cin>>code;
    while(!emp_data.eof())
    {
    emp_data.getline(emp_rec,sizeof(emp_data));
    tok=strtok(emp_rec,smiled);
    while(tok)
    {
    if(x==1)
    strcpy(name,tok);
    if(x==2)
    strcpy(empcode,tok);
    if(x==3)
    {
    strcpy(level,tok);
    x=0;
    }
    tok=strtok(NULL,smiled);
    x++;
    }
    if(strcmpi(code,empcode)==0)
    goto FOUND;
    }
    }
    else

    puts("\nUnable to Open File! ");

    if(found==0)
    {
    puts("\nEMployee Code not Found!");
    delay(2000);
    exit(0);
    }
    /// till here,,, i dont know what to do !,, because im a newbie in java and this is my // final project!,, hope u can help me,,, thanks in advance

    FOUND:

    cout<<"\Employee Name: ";
    countname=strlen(name);
    while(n<countname)
    {
    if(name[n]==',')
    cout<<"";
    else
    cout<<name[n];
    n++;
    }

    if((strcmpi(level,"1")==0))
    strcpy(rate,"380");
    else if((strcmpi(level,"2")==0))
    strcpy(rate,"450");
    else if((strcmpi(level,"3")==0))
    strcpy(rate,"550");
    cout<<"\nEmployee Code: "<<empcode;
    cout<<"\nSalary Level: "<<level;
    cout<<"\nSalary Rate: "<<rate<<"/day";

    while(y<5)
    {
    line();
    cout<<"\nEnter Time-in for "<<days[y]<<":";
    cin>>timein;
    cout<<"\nEnter Time-out for "<<days[y]<<":";
    cin>>timeout;

    strcat(dtrtime,timein);
    strcat(dtrtime,",");
    strcat(dtrtime,timeout);
    strcat(dtrtime,",");

    tin=strtok(timein,tdelim);
    tinhr=atoi(tin);
    tin=strtok(NULL,tdelim);
    tinmi=atoi(tin);
    tout=strtok(timeout,tdelim);
    touthr=atoi(tout);
    tout=strtok(NULL,tdelim);
    toutmi=atoi(tout);

    if((tinhr>0)&&(touthr>0))
    {
    if(tinhr>=8)
    late=late+tinmi;
    if((touthr<17)&&(toutmi !=0))
    undertime=undertime+(60-toutmi);

    hoursworked=touthr-tinhr;

    if(hoursworked>8)
    hoursworked=8;

    cout<<"Is "<<days[y]<<" a holiday? [y/n] :";
    cin<:ans;

    if((ans == 'Y')&&(ans == 'y'))
    {
    holidayhours = holidayhours + hoursworked;
    totalhours = totalhours + holidayhours
    }
    else
    totalhours=totalhours + hoursworked;

    cout<<"\nEnter Overtime in for "<<days[y]<<":";
    cin>>otin;
    cout<<"\nEnter Overtime out for "<<days[y]<<":";
    cin>>otout;

    othours = atoi(otout) - atoi(otin);
    totalot = othours + holidayhours

    }
    y++;
    }

    totalhours = totalhours - ((late + undertime)/60);

    line();
    cout<<"\n\nEnter Coverage Date: ";
    gets(date);

    salrate=atoi(rate);
    regincome = (salrate/8)*totalhours;
    otincome = totalot * ((salrate/8)*1.1);
    grossincome = otincome + regincome;


    dtr.open("C:\\Payroll\\Dtr.txt",ios::app);

    dtr<<empcode<<","<<date<<","<<dtrtime<<totalhours< <","<<regincome<<","<<endl;

    cout<<setiosflags(ios::fixed | ios::showpoint|ios::right)
    <<setprecision(2);
    line();

    cout<<"\nEmployee Name: ";
    n=0;
    while(n<countname)
    {
    if(name[n]==',')
    cout<<"";
    else
    cout<<name[n];
    n++;
    }

    cout<<"\nEmployee Code: "<<empcode;
    cout<<"\nSalary Level: Level "<<level;
    cout<<"\nSalary Rate : Php "<<rate<<"/day";
    line();
    cout<<"\nDate Covered: "<<date;
    cout<<"\nTotal Number of Work Hours: "<<totalhours<<" Hrs. ";
    cout<<"\nTotal Overtime Hours: "<<totalot<<" Hrs. ";
    cout<<"\nRegular Income: Php "<<regincome;
    cout<<"\nOvertime Income: Php "<<otincome;
    cout<<"\nGross Income: Php "<<grossincome;
    line();

    getch();
    return 0;
    }

    void line()
    {
    cout<<endl<<"_____________________________________ __________________"<<endl;
    }



    // thank in advance!!,,, God bless!
    Last edited by eduard; 02-06-2011 at 05:14 AM.

  2. #2
    Iron Lion is offline Senior Member
    Join Date
    Nov 2010
    Posts
    210
    Rep Power
    5

    Default

    What have you tried? Which parts are you having problems with?

  3. #3
    doWhile is offline Moderator
    Join Date
    Jul 2010
    Location
    California
    Posts
    1,641
    Rep Power
    7

    Default

    If you are posting this with the expectation that someone will port the code for you, you are mistaken. Show an effort that you have made and describe any problems you encounter in detail and you may receive more specific help.

  4. #4
    pbrockway2 is offline Moderator
    Join Date
    Feb 2009
    Location
    New Zealand
    Posts
    4,574
    Rep Power
    12

    Default

    God bless!

    That's all very well, but it won't pay the rent or buy the groceries. If you want someone to write some code for you then you (or the deity of your choice) had better come up with some cash: because that's what the landlord and the shopkeeper demand.

    (Not to mention the need for a Mercedes Benz, colour TV etc.)

    -----------------------

    Seriously, write your own code. People here will help with that.

  5. #5
    Fubarable's Avatar
    Fubarable is offline Moderator
    Join Date
    Jun 2008
    Posts
    19,316
    Blog Entries
    1
    Rep Power
    26

    Default

    Quote Originally Posted by pbrockway2 View Post
    (Not to mention the need for a Mercedes Benz, colour TV etc.)
    I assume that your "ect." includes a night on the town? I'm counting on you lord, please don't let me down.

  6. #6
    pbrockway2 is offline Moderator
    Join Date
    Feb 2009
    Location
    New Zealand
    Posts
    4,574
    Rep Power
    12

    Default

    Sure does! And I deserve it, too. @OP note this

    "Worked hard all my lifetime, no help from my friends"

    (Except that we do help, we just don't hand out.)

    --------------------------------------

    And here was I thinking you might rebuke me for leading this thread down metaphysical pathways in contravention of some TOS clause or other... ;)

  7. #7
    eduard is offline Member
    Join Date
    Feb 2011
    Posts
    5
    Rep Power
    0

    Default

    sorry for miss conversation for my english what i trying to say to my post is from the starting codes i dont know how to convert the codes (int main to found),when i enter employee Id and it will read from (Employee.txt) the information and it will need a tokenization.. sorry for my bad english,,, From (Found:) condition to last i already converted and its working,,, this is my

    (Employee.txt)

    name , employee Id,level

    Juan_DelaCruz,X10-0001,1
    Philip_Palanca,X10-0003,3
    June_Asistio,X10-0002,3
    Oscar_Tallens,X10-0005,2
    Antonio_Cruzat,X10-0004,1


    thank you in advance,, i hope youl understand what im trying to say!
    Last edited by eduard; 02-06-2011 at 05:11 AM.

  8. #8
    eduard is offline Member
    Join Date
    Feb 2011
    Posts
    5
    Rep Power
    0

    Default

    sorry for miss conversation for my english what i trying to say to my post is from the starting codes i dont know how to convert the codes (int main to found),when i enter employee Id and it will read from (Employee.txt) the information and it will need a tokenization.. sorry for my bad english,,, From (Found condition to last i already converted and its working,,, this is my (Employee.txt)


    Juan_DelaCruz,X10-0001,1
    Philip_Palanca,X10-0003,3
    June_Asistio,X10-0002,3
    Oscar_Tallens,X10-0005,2
    Antonio_Cruzat,X10-0004,1


    thank you in advance,, i hope youl understand what im trying to say!

  9. #9
    Fubarable's Avatar
    Fubarable is offline Moderator
    Join Date
    Jun 2008
    Posts
    19,316
    Blog Entries
    1
    Rep Power
    26

    Default

    I think we understood you clearly and the reply is the same: your options are to learn C/C++ and Java and translate this code yourself (and we can help with the Java part, but you have to ask specific questions that are answerable), or you may wish to pay someone to do the translation for you.

  10. #10
    eduard is offline Member
    Join Date
    Feb 2011
    Posts
    5
    Rep Power
    0

    Default

    i dont have money to pay,, thats why i post my codes to this thread in case someone can help me,thats why o cant translate that code on that part because i dont have any idea how to convert that codes ,,, im just a poor student,, by the way thakns a lot for your reply,, i really appreciate this,, sorry again for my bad english,, godbless!

  11. #11
    Fubarable's Avatar
    Fubarable is offline Moderator
    Join Date
    Jun 2008
    Posts
    19,316
    Blog Entries
    1
    Rep Power
    26

    Default

    Quote Originally Posted by eduard View Post
    i dont have money to pay,, thats why i post my codes to this thread in case someone can help me,thats why o cant translate that code on that part because i dont have any idea how to convert that codes ,,, im just a poor student,, by the way thakns a lot for your reply,, i really appreciate this,, sorry again for my bad english,, godbless!
    Again, this is not a code bank, and I see that we're going nowhere with this thread, so I'm closing it. I suggest you put in the effort to learn C and Java so that you can solve this yourself.
    Last edited by Fubarable; 02-06-2011 at 05:53 AM.

Similar Threads

  1. Replies: 1
    Last Post: 01-21-2011, 12:46 PM
  2. someone help me debug...this plzz
    By andys in forum New To Java
    Replies: 3
    Last Post: 11-28-2010, 12:17 PM
  3. plzz help me to solve this program
    By Gayathri12 in forum New To Java
    Replies: 2
    Last Post: 07-20-2010, 06:15 PM
  4. Replies: 1
    Last Post: 07-06-2010, 03:38 AM
  5. Doubt Plzz Solve it
    By ravjot28 in forum New To Java
    Replies: 3
    Last Post: 06-27-2008, 05:14 AM

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •