Results 1 to 11 of 11
- 02-05-2011, 08:47 AM #1
Member
- Join Date
- Feb 2011
- Posts
- 5
- Rep Power
- 0
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 04:14 AM.
- 02-05-2011, 10:35 AM #2
Senior Member
- Join Date
- Nov 2010
- Posts
- 210
- Rep Power
- 3
What have you tried? Which parts are you having problems with?
- 02-05-2011, 05:06 PM #3
Moderator
- Join Date
- Jul 2010
- Location
- California
- Posts
- 1,609
- Rep Power
- 5
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.
- 02-05-2011, 05:42 PM #4
Moderator
- Join Date
- Feb 2009
- Location
- New Zealand
- Posts
- 4,547
- Rep Power
- 11
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.
-
- 02-05-2011, 06:03 PM #6
Moderator
- Join Date
- Feb 2009
- Location
- New Zealand
- Posts
- 4,547
- Rep Power
- 11
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... ;)
- 02-06-2011, 04:05 AM #7
Member
- Join Date
- Feb 2011
- Posts
- 5
- Rep Power
- 0
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 04:11 AM.
- 02-06-2011, 04:06 AM #8
Member
- Join Date
- Feb 2011
- Posts
- 5
- Rep Power
- 0
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!
-
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.
- 02-06-2011, 04:24 AM #10
Member
- Join Date
- Feb 2011
- Posts
- 5
- Rep Power
- 0
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!
-
Last edited by Fubarable; 02-06-2011 at 04:53 AM.
Similar Threads
-
Plzz Help...Issue when doing Text Printing from Java to Canon iR1018, iR1020
By rameshZSL in forum Advanced JavaReplies: 1Last Post: 01-21-2011, 11:46 AM -
someone help me debug...this plzz
By andys in forum New To JavaReplies: 3Last Post: 11-28-2010, 11:17 AM -
plzz help me to solve this program
By Gayathri12 in forum New To JavaReplies: 2Last Post: 07-20-2010, 05:15 PM -
Can not get the way to remove the exception help plzz
By ravjot28 in forum New To JavaReplies: 1Last Post: 07-06-2010, 02:38 AM -
Doubt Plzz Solve it
By ravjot28 in forum New To JavaReplies: 3Last Post: 06-27-2008, 04:14 AM


LinkBack URL
About LinkBacks


Bookmarks