I need everything to come out as a double rather than an int. I dont know how to do this other than creating lots of variables! Is there a way i can convert? my counter is causing the problem but i dont think theres another way to do it.The program simply prints 10 peoples wages, in an array, then it prints the bonus based on a per cent, then the total inc bonus!! and stores the new total in a new array, called total. .....any help would be appreciated
public class Salary
public void calcSalary()
final int TOTAL_LENGTH=10; //declare constant
int total=new int[TOTAL_LENGTH];
for (counter=0; counter <total.length; counter++)
System.out.printf("\n\n\n%s\t%10s\n\n","BONUS","TOTAL"); //column headings
if (wages[counter]>19000 && wages[counter]<=40000)
1. You should have posted in the Java Forum for experienced Java users to see this post
2. Why make a duplicate thread about the same problem with your last thread?
3. Are the suggestions in the other thread not helpful?
i need all the data in my array wages, total and my bonus variable to be doubles.The problem is, i need to use my counter as an int , and i need it as it calculates the totals for me, i need a way of getting around this, rather than just creating lots of different variables. I cant calculate with an int and a double together thats my issue
These are wrong, the arguments used here are not variables
1.Initialize the variables bonus and total array as double(no need to change variable counter as a double)
2. use %f at the printf statements for the variables which are double
3. use these for precision