| | |
java code problem
Please support our Java advertiser: Programming Forums - DaniWeb Sister Site
![]() |
•
•
Join Date: Sep 2004
Posts: 24
Reputation:
Solved Threads: 0
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......????
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......????
![]() |
Similar Threads
- Help - Basic Java GUI problem (Java)
- Java MIDlet problem (Java)
- java sorting problem (Java)
- Java newb w/ code problem (Java)
- Help...I need Java code..... (Java)
- refresh and java code? (HTML and CSS)
- Java code to compare XML files (Java)
- Help with Java code (Java)
- Can N E 1 Help!!!! -- Need sample Java code (Java)
- java code newbie (Java)
Other Threads in the Java Forum
- Previous Thread: tool for converting java/sql codes to asp.net/sqol2000
- Next Thread: find out the error in my code
| Thread Tools | Search this Thread |
actuate android api applet application array arrays automation balls binary bluetooth bold business c++ chat class classes client code codesnippet collections component coordinates database defaultmethod doctype dragging draw ebook eclipse educational error event exception file fractal froglogic game givemetehcodez graphics gui hql html ide image ingres input integer internet intersect invokingapacheantprogrammatically j2me java javaexcel javaprojects jni jpanel jtextarea julia linux list loop looping map method methods mobile mysql netbeans newbie nextline numbers oracle parameter php print problem program programming project recursion recursive scanner screen server set size sms sort sql string sun swing swt threads time tree user websites windows





