Welcome to Dream.In.Code
Become a Java Expert!

Join 150,410 Java Programmers for FREE! Get instant access to thousands of Java experts, tutorials, code snippets, and more! There are 952 people online right now. Registration is fast and FREE... Join Now!




please find the loop statement for the program

 
Reply to this topicStart new topic

please find the loop statement for the program

Thapelo
18 Mar, 2008 - 12:36 PM
Post #1

New D.I.C Head
*

Joined: 11 Mar, 2008
Posts: 1

java

import java.io.*;


class employee

{

void capture() throws IOException

{ String num;

int hours_worked;
double incomeSalary;
double salary =0.0;
//int a;
BufferedReader in = new BufferedReader(new InputStreamReader(System.in));
/* System.out.print("enter 1(one) to stop or any number to continue");
num=in.readLine();
int a= Integer.parseInt(num);
while(a!=1)*/
{



System.out.print("\nENTER YOUR PERSONAL NUMBER: ");
int pnum = Integer.valueOf(in.readLine()).intValue();

System.out.print("\n************THESE IS YOUR PROFILE:******************** ");
System.out.print("\n\nPERSONEEL NUMBER\tEMPLOYEE NAME\tPOSITION\tRATE/HOUR: ");
System.out.print("\n=================\t=============\t========\t========= ");




switch(pnum)

{
//float salary =0.0;

case 4583170 :{


System.out.println("\n4583170\t\t\t\tMYBURGH S\t\t ARTISAN\t\tR50.00");
//System.out.println ("artisan");

System.out.print("ENTER THE HOURS WORKED THIS WEEK: ");
num=in.readLine();
int hours= Integer.parseInt(num);


if(hours <=40 )
{

salary = hours * 50;


System.out.print("ur salary is: "+salary);
}


else
if((hours >40) && (hours <=50 ))
{salary = hours *(1.5)* 50;


System.out.print("ur salary is: "+salary);


}



else
{
salary = hours *((2)*50);
System.out.print(" ur salary is: R"+salary);



}}

incomeSalary=salary*0.4;

System.out.println("\nincomeSalary is: "+incomeSalary);
break;




case 4583171:{

System.out.println("MILLER B");

System.out.print("ENTER THE HOURS WORKED THIS WEEK: ");

num=in.readLine();
int hours= Integer.parseInt(num);


if(hours <=40 )
{

salary = hours * 75;

System.out.print("ur salary is: "+salary);
}


else if((hours >40) && (hours <=50 ))
{salary = hours *(1.5)* 75;


System.out.print("ur salary is: "+salary);
}


else
{ salary = hours *((2)*75);
System.out.print("ur salary is: "+salary);
} }
break;

case 4583172:{

System.out.println("COOK R");

System.out.print("ENTER THE HOURS WORKED THIS WEEK: ");


num=in.readLine();
int hours= Integer.parseInt(num);


if(hours <=40 )
{

salary = hours * 90;

System.out.print("ur salary is: "+salary);
}


else if((hours >40) && (hours <=50 ))
{salary = hours *(1.5)* 90;


System.out.print("ur salary is: "+salary);
}


else
{ salary = hours *((2)*90);
System.out.print("ur salary is: "+salary);
}
}
break;

case 4583173:{

System.out.println("JONES V");
System.out.print("ENTER THE HOURS WORKED THIS WEEK: ");

num=in.readLine();
int hours= Integer.parseInt(num);


if(hours <=40 )
{

salary = hours * 100;

System.out.print("ur salary is: "+salary);
}


else if((hours >40) && (hours <=50 ))
{salary = hours *(1.5)* 100;


System.out.print("ur salary is: "+salary);
}


else
{ salary = hours *((2)*100);
System.out.print("ur salary is: "+salary);
}

}
break;

default:System.out.println("PERSONAL NUMBER DOES NOT MATCH");
break;

//5System.out.print("enter 1(one) to stop or any number to continue");
/* num=in.readLine();
a= Integer.parseInt(num);
*/

}

}
//while(a!=1)
}

public static void main(String[] args) throws IOException

{

employee d = new employee ();

d.capture();

}

}

*edit: Please use code tags in the future, thanks! code.gif

This post has been edited by Martyr2: 18 Mar, 2008 - 01:00 PM


Attached File(s)
Attached File  question_for__.doc ( 32.5k ) Number of downloads: 20
User is offlineProfile CardPM
+Quote Post

Martyr2
RE: Please Find The Loop Statement For The Program
18 Mar, 2008 - 01:19 PM
Post #2

Programming Theoretician
Group Icon

Joined: 18 Apr, 2007
Posts: 5,660



Thanked: 314 times
Expert In: C/C++, Java, VB, VB.NET, C#, PHP, Web Development, HTML & CSS, Javascript

My Contributions
I am not quite sure what you are asking exactly. You have what appears to be a loop in there, but you commented it out. Was it not working for you? If it wasn't working, what was it doing wrong? Describe the problem please.

I also wanted to mention something that appears to be a common error with these types of assignments. You attempt to apply pay rates times all the hours someone works which is not right. It is a pay changing system.

For instance, if they work <= 40 it is their common rate. This is 40 * rateperhour. Fine this works ok. BUT for hours above 40 and less than or equal to 50 is time and a half. This is NOT hours * (1.5). This is ((hours - 40) * 1.5). Notice that I subtract the first 40 hours. You don't get time and a half for all the hours you worked. Only for those hours up and beyond the first 40. Then when you get up over 50 you have to do ((hours - 40) - 10) to give you the number of hours over 50. So if the person worked 70 hours, you would charge 40 hours at normal rate, 10 hours at 1.5 rate and 20 hours that doubles the rate for each hour.

So make sure you make the changes to handle that and double check your equations for the double of pay every hour over 50 because for an artisan it is 100 dollars per hour... the first hour over 50 is 100, the second hour is then double that 200 and the third hour over 50 is then 400 etc etc.

Good luck. smile.gif
User is offlineProfile CardPM
+Quote Post

Fast ReplyReply to this topicStart new topic
Time is now: 1/9/09 07:38PM

Be Social

Dream.In.Code RSS Feed Dream.In.Code LinkedIn Group Follow Us On Twitter

Live Java Help!

Java Tutorials

Reference Sheets

Java Snippets

DIC Chatroom

Bye Bye Ads

Monthly Drawing

Thumb Drive

Top Contributors

Top 10 Kudos This Month