Results 1 to 6 of 6
Thread: need some help in looping
- 12-24-2012, 12:26 PM #1
Member
- Join Date
- Dec 2012
- Posts
- 3
- Rep Power
- 0
need some help in looping
Hi .. I am new here , so i realy need some help in addaing a loop into this
final double B1= .15;
final double B2 = .10;
final double B3 = .06;
final double B4 = 0.00;
switch(employeeRating)
{
case 1: employeeBonus = (employeeSalary * B1);
break;
case 2: employeeBonus = (employeeSalary * B2);
break;
case 3: employeeBonus = (employeeSalary * B3);
break;
}
- 12-24-2012, 01:22 PM #2
AN21XX
- Join Date
- Mar 2012
- Location
- Munich
- Posts
- 297
- Rep Power
- 2
Re: need some help in looping
This is no valid java class... before you implement a loop make it a class and use the forum code tags to make your code readable.
Describe what you already did, what you actual problem is and what proposal you have to solve it.I like likes!.gif)
- 12-24-2012, 01:43 PM #3
Member
- Join Date
- Dec 2012
- Posts
- 3
- Rep Power
- 0
Re: need some help in looping
i didnt get it realy
.gif)
so this is the whole program , i wanted to add an aray and a loop but i didnt know how !
could you tell me what to do, please ?
import javax.swing.JOptionPane;
public class Array {
public double employeeBonus;
static String[] info ={"employeeName","salary","rating"};
public static void main(String[] args) {
String employeeName, salaryString, ratingString;
double employeeSalary;
double employeeBonus = 0;
int employeeRating;
final double B1= .20;
final double B2 = .15;
final double B3 = .10;
final double B4 = 0.00;
final int RATING1 = 1;
final int RATING2 = 2;
final int RATING3 = 3;
// This is the work done in the housekeeping() method
// Get user input.
employeeName = JOptionPane.showInputDialog("Enter employee's name: ");
salaryString = JOptionPane.showInputDialog("Enter employee's yearly salary: ");
ratingString = JOptionPane.showInputDialog("Enter employee's performance rating: ");
// Convert Strings to int or double.
employeeSalary = Double.parseDouble(salaryString);
employeeRating = Integer.parseInt(ratingString);
switch(employeeRating)
{
case 1: employeeBonus = (employeeSalary * B1);
break;
case 2: employeeBonus = (employeeSalary * B2);
break;
case 3: employeeBonus = (employeeSalary * B3);
break;
}
// This is the work done in the endOfJob() method
// Output.
System.out.println("Employee Name " + employeeName);
System.out.println("Employee Salary $" + employeeSalary);
System.out.println("Employee Rating " + employeeRating);
System.out.println("Employee Bonus $" + employeeBonus);
System.exit(0);
- 12-24-2012, 02:38 PM #4
AN21XX
- Join Date
- Mar 2012
- Location
- Munich
- Posts
- 297
- Rep Power
- 2
Re: need some help in looping
You may do loop in different ways it depends on what you are trying to archieve, right?
A loop is a very basic thing, I suggest you read one of the tutorials on that matter, there are two basic types of loops:
- for (...) { ... }
- while(...) { ... }
And as I said - as long as you do not say what you want to do we cannot help you. As I also said, use the forum code tags to make your code readable!
EDIT: I guess you want to read in multiple employees, is that correct?Last edited by Sierra; 12-24-2012 at 02:40 PM.
I like likes!.gif)
- 12-24-2012, 02:55 PM #5
Member
- Join Date
- Dec 2012
- Posts
- 3
- Rep Power
- 0
Re: need some help in looping
ok, i just need to ask you a couple questions , if you dont mind :)
Q1 : i want to calculate the imployee bonus , can i add a loop in it ?
Q2 : i want to add an array , is my array correct or not ?
static String[] info ={"employeeName","salary","rating"};
- 12-24-2012, 03:15 PM #6
Re: need some help in looping
Please go through Guide For New Members and BB Code List - Java Programming Forum - Learn Java Programming and edit your posts accordingly.
dbWhy do they call it rush hour when nothing moves? - Robin Williams
Similar Threads
-
Looping: Help Please
By michelle_323 in forum New To JavaReplies: 5Last Post: 10-12-2011, 11:59 AM -
Looping issue
By sehudson in forum New To JavaReplies: 3Last Post: 07-11-2011, 06:05 PM -
Looping
By Dean29126 in forum New To JavaReplies: 3Last Post: 09-08-2010, 02:01 PM -
Help with While and For Looping
By gmoney8316 in forum New To JavaReplies: 2Last Post: 03-03-2010, 10:54 PM -
Looping Help Please
By JonnySnip3r in forum New To JavaReplies: 5Last Post: 01-31-2010, 05:57 AM


LinkBack URL
About LinkBacks
Reply With Quote
Bookmarks