0

I want to output the annual salary for each employee individually but I'm not sure how. The way it is now it just pops up as one large box.

Any help is much appreciated :)

 public static void main(String[] args) {
        // TODO code application logic here


    String increase, 
            Salary,    
            output = "";


    double percentIncrease, 
            AnnualSalary,
            AnnualSal;





    for(int count = 1; count <= 10; count++ ){

        Salary = JOptionPane.showInputDialog("Enter Employee wage " + count );

        AnnualSalary = Double.parseDouble(Salary);

        increase = JOptionPane.showInputDialog("Enter Percentage Increase for Employee " + count);

        percentIncrease = Double.parseDouble(increase);

        for(int year = 1; year <= 4; year++ ){

             AnnualSalary += ( percentIncrease / 100 )* AnnualSalary;

             output += "The new salary for year " +  count  + " is " +  + AnnualSalary + "\n";

        }



    }

    JOptionPane.showMessageDialog(null, output);

    System.exit(0);
         }
    }
3
Contributors
2
Replies
14
Views
2 Years
Discussion Span
Last Post by Nation
1

did you write this code yourself ? somehow, it seems to me that if you did, you would have know how to do so.

in your iteration, don't add the text to print to a variable called output, just put the JOptionPane.showMessageDialog as last command in the loop, and replace the 'output' variable by the text to print.

Votes + Comments
My tutor help me out with the code but did not in to detail about the output message, that and I'm a bit rusty after the Christmas break
1

you said, "I want to output the** annual** salary ".It means in your output message you should include the the variable that is storing this value.
for example:System.out.println(myAnnualVariable);. However, in your case use
JOptionPane.showMessageDialog.

Votes + Comments
Thanks for the help :)
This topic has been dead for over six months. Start a new discussion instead.
Have something to contribute to this discussion? Please be thoughtful, detailed and courteous, and be sure to adhere to our posting rules.