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()
{
int wages[]={50000,40000,30000,20000,10000,60000,35000,46000,23000,19000};
final int TOTAL_LENGTH=10; //declare constant
int total[]=new int[TOTAL_LENGTH];
int bonus;
int counter;
System.out.printf("\n%s\t%11s\n\n","REP","SALARY");
for (counter=0; counter <total.length; counter++)
System.out.printf("%2d\t%10d\n",counter, wages[counter]);
counter=0;
System.out.printf("\n\n\n%s\t%10s\n\n","BONUS","TOTAL"); //column headings
while (counter<total.length)
{
if (wages[counter]<=19000)
{
bonus=wages[counter]/100*30;
total[counter]=wages[counter]+bonus;
System.out.printf("%d\t%10d\n",bonus,total[counter]);
}
if (wages[counter]>19000 && wages[counter]<=40000)
{
bonus=wages[counter]/100*20;
total[counter]=wages[counter]+bonus;
System.out.printf("%d\t%10d\n",bonus,total[counter]);
}
if (wages[counter]>40000)
{
bonus=wages[counter]/100*10;
total[counter]=wages[counter]+bonus;
System.out.printf("%d\t%10d\n",bonus,total[counter]);
}
counter=counter+1;
}
}
}