Results 1 to 6 of 6
  1. #1
    toume is offline Member
    Join Date
    Dec 2012
    Posts
    3
    Rep Power
    0

    Default 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;
    }

  2. #2
    Sierra is offline AN21XX
    Join Date
    Mar 2012
    Location
    Munich
    Posts
    297
    Rep Power
    3

    Default 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!

  3. #3
    toume is offline Member
    Join Date
    Dec 2012
    Posts
    3
    Rep Power
    0

    Default Re: need some help in looping

    i didnt get it realy

    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);

  4. #4
    Sierra is offline AN21XX
    Join Date
    Mar 2012
    Location
    Munich
    Posts
    297
    Rep Power
    3

    Default 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!

  5. #5
    toume is offline Member
    Join Date
    Dec 2012
    Posts
    3
    Rep Power
    0

    Default 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"};

  6. #6
    DarrylBurke's Avatar
    DarrylBurke is offline Forum Police
    Join Date
    Sep 2008
    Location
    Madgaon, Goa, India
    Posts
    11,404
    Rep Power
    20

    Default 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.

    db
    If you're forever cleaning cobwebs, it's time to get rid of the spiders.

Similar Threads

  1. Looping: Help Please
    By michelle_323 in forum New To Java
    Replies: 5
    Last Post: 10-12-2011, 11:59 AM
  2. Looping issue
    By sehudson in forum New To Java
    Replies: 3
    Last Post: 07-11-2011, 06:05 PM
  3. Looping
    By Dean29126 in forum New To Java
    Replies: 3
    Last Post: 09-08-2010, 02:01 PM
  4. Help with While and For Looping
    By gmoney8316 in forum New To Java
    Replies: 2
    Last Post: 03-03-2010, 10:54 PM
  5. Looping Help Please
    By JonnySnip3r in forum New To Java
    Replies: 5
    Last Post: 01-31-2010, 05:57 AM

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •