File APIs for Java Developers
Manipulate DOC, XLS, PPT, PDF and many others from your application.
http://aspose.com/file-tools
The moose likes Java in General and the fly likes java code problem Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login
JavaRanch » Java Forums » Java » Java in General
Bookmark "java code problem" Watch "java code problem" New topic
Author

java code problem

Morgan mor
Greenhorn

Joined: Nov 03, 2004
Posts: 11
Please help me!
My program does not work
1-I have problem wihte constructors parameters
2-I have problem whit toString methode.
User writes(from keyboard): workers name, hourPayment,
and time(how many hours he has worked, first week, second week....).
The out put is like this:
his(name) salary is.....$ for first week
his(name) salary is.....$ for second week
his overtime is.....hours.
his(name) salary is.....$ for third week
// we should write while(time!=0)
If the user writes Zero(0);
the program computes totalOverTime and total salary
and prints out also workers name and hourPayment.
pree any key to continue....
//------------------------------------------------------
class mySalary{
public static void main(String[]args){
System.out.print("write name:");

Salary ans= new Salary();
String name=Input.readString();

System.out.print("write hourPayment");
double hourPayment=Input.readInt();
ans.getHourPayment();


System.out.print("Write"+name+" "+"houre for first week");
int f=Input.readInt();

double count1=ans.compute(f);
System.out.println(name+"salary for first week is:"+" "+count1);
System.out.println();

System.out.print("Write"+name+" "+"houre for secound week");
int f2=Input.readInt();
double count2=ans.compute(f2);

System.out.println(name+"salary for second week is:"+" "+count2);}}
System.out.println();
//--------------------------------------------
class Salary{
private String name;
private double hourPayment;
private int .....;
private double totaltOvertim;
private double ....;

public Salary(String name, double hourPayment, int ...,int totaltOvertim){
this.name= name;
this.hourPayment=hourPayment;
this.;
this.totaltOvertim=totaltOvertim;}
public String getNamn(){
return name;}
public double getHourPayment(){
return hourPayment;}
public double compute(int time){
// he has worked less than 40 hours
if(time<=40){
salary=hourPayment*time;
System.out.println(salary);}
else if(time>40){
//it is just a formula for over time.
overTidsPayment=(((40*hourPayment)+(time-40)*(3/2)*hourPayment));
salary=salary+overTidsPayment;
System.out.println("???"+(salary));
}
else if(time>70){
// If he works 30 hours over time he gets warning.
double overTidsPayment=(((40*hourPayment)+(time-40)*(3/2)*hourPayment));
salary=salary+overTidsPayment;
System.out.println("???"+(salary));
System.out.println("WARNING: You have worked more than 70(40+30) hour");
}
return salary;
}
public String toString(){
return......???
Jeff Bosch
Ranch Hand

Joined: Jul 30, 2003
Posts: 804
Hi, Morgan -

I'd be happy to look at your code if you will please use the CODE UBB tags to format it. Otherwise it's just too hard for me to read.

Thanks.


Give a man a fish, he'll eat for one day. Teach a man to fish, he'll drink all your beer.
Cheers, Jeff (SCJP 1.4, SCJD in progress, if you can call that progress...)
Jeff Bosch
Ranch Hand

Joined: Jul 30, 2003
Posts: 804
Hi, Morgan -

Your second post looks just like the first one. It should resemble this snippet:


Notice how the formatting is preserved? To preserve the formatting, click the "Instant UBB Code" button marked "CODE", then paste your formatted code between the opening and closing tags.

Thanks.
Anand Karia
Ranch Hand

Joined: Sep 25, 2004
Posts: 156

I think he dont know how to use UBB Code. Well i m doing for.

Please help me!
My program does not work
1-I have problem wihte constructors parameters
2-I have problem whit toString methode.
User writes(from keyboard): workers name, hourPayment,
and time(how many hours he has worked, first week, second week....).

The out put is like this:
his(name) salary is.....$ for first week
his(name) salary is.....$ for second week
his overtime is.....hours.
his(name) salary is.....$ for third week
// we should write while(time!=0)
If the user writes Zero(0);
the program computes totalOverTime and total salary
and prints out also workers name and hourPayment.
pree any key to continue....

//------------------------------------------------------


Love is GOD and GOD is Love.
Anand Karia
IT Concretor.......
M/s. Anand Karia Concreting IT
Morgan mor
Greenhorn

Joined: Nov 03, 2004
Posts: 11
kumm redd
Ranch Hand

Joined: Nov 02, 2004
Posts: 31
kumm redd
Ranch Hand

Joined: Nov 02, 2004
Posts: 31
hi all

sorry..was just trying out myself with UBB coding..got it?
sorry for inconvenience.

regards
reddy
kumm redd
Ranch Hand

Joined: Nov 02, 2004
Posts: 31
hi morgan
the follwing would work as you intended. please check it out








Regards
reddy
Morgan mor
Greenhorn

Joined: Nov 03, 2004
Posts: 11
Hi raj reddy!
Your code is working.
Thank you very much.
Regards
Morgan
 
I agree. Here's the link: http://aspose.com/file-tools
 
subject: java code problem
 
Similar Threads
Problems searching through a list
Identifier expected
Need help with structure...
Ternary Operator behavior in JAVA
using doubleToString