# Employee Salary Calculator

Page 1 of 1

## 2 Replies - 653 Views - Last Post: 16 June 2015 - 02:40 PMRate Topic: //<![CDATA[ rating = new ipb.rating( 'topic_rate_', { url: 'http://www.dreamincode.net/forums/index.php?app=forums&module=ajax&section=topics&do=rateTopic&t=377488&amp;s=01aace55bcc5ce55d01640098a4ed777&md5check=' + ipb.vars['secure_hash'], cur_rating: 0, rated: 0, allow_rate: 0, multi_rate: 1, show_rate_text: true } ); //]]>

### #1 Demongo

Reputation: 0
• Posts: 2
• Joined: 16-June 15

# Employee Salary Calculator

Posted 16 June 2015 - 02:08 PM

I'm not sure whats going on. I am not getting any errors, but after line 38....nothing happens. I am new to this whole java/ programming thing. A nudge in the right direction would be most appreciated because I am at my wits ends with this thing. It is suppose to ask for a company and then provide the sum of the column, the avg, and then the number of employees. I don't want it done for me, I am just in over my head with these multidimentional arrays.

```mport java.util.Scanner;
import java.text.NumberFormat;

public class comp
{
public static void main (String [ ] args )
{

//multidiementional array with employeeSalary data
int[][] employeeSalary = new int[][] {  { 49920, 45519, 54619},
{ 50831, 47373, 48339},
{ 39430, 36824, 44260},
{ 54697, 51229, 44390},
{ 41751, 36966, 39732},
{ 36110, 40332, 44073},
{ 41928, 53294, 53308},
{ 48460, 44907, 35459},
{ 39714, 36050, 52448},
{ 49271, 51574, 38364},
{ 51713, 39758, 39990},
{ 38903, 53847, 47373} };

//lets you select a company
String [] compName = { "Alhermit", "Logway", "felter" };
for ( int i = 0; i < compName.length; i++ )
System.out.println( " Company Number " + i + " : " + compName [i] );

Scanner scan = new Scanner( System.in );
int currentName;
do
{
System.out.print( "Select Company Number > ");
currentName = scan.nextInt( );
}while ( currentName < 0 || currentName > 2);
}
//calculates and prints total employeeSalary of chosen company
public int salTot(int n,int[][] employeeSalary )
{
int sum=0;
int leng=employeeSalary[n].length;
for(int i=0;i<leng;i++)
sum=sum+employeeSalary[n][i];
System.out.println("Total Salary is: "+sum);
return sum;
}
//calculates and prints out avg of selected company
public double salAvg(int n,int[][] employeeSalary )
{
double avg=0;
int sum=0;
int leng=employeeSalary[n].length;
for(int i=0;i<leng;i++)
sum=sum+employeeSalary[n][i];
avg=sum/leng;
System.out.println("Average Salary is: "+avg);
return avg;
}
//calculates and prints total employees
public int totEmp(int n,int[][] employeeSalary )
{
int leng=employeeSalary[n].length;
System.out.println("Number of employees is: " +leng );
return leng;

}

}

```

line 43 and on isn't working...I am not sure what I am not doing right to get it to initialize

This post has been edited by macosxnerd101: 16 June 2015 - 02:07 PM
Reason for edit:: Renamed title to be more descriptive

Is This A Good Question/Topic? 0

## Replies To: Employee Salary Calculator

### #2 macosxnerd101

• Games, Graphs, and Auctions

Reputation: 11759
• Posts: 44,185
• Joined: 27-December 08

## Re: Employee Salary Calculator

Posted 16 June 2015 - 02:12 PM

Welcome to Dream.in.Code!

Note that any code in your main() method gets executed. So the last statements in your main() method are the loop to prompt for the index of the company. You don't tell your program to do anything after the do-loop.

You have the salTot, salAvg, and totEmp methods. You might want to invoke them (after making them static methods first).

### #3 Demongo

Reputation: 0
• Posts: 2
• Joined: 16-June 15

## Re: Employee Salary Calculator

Posted 16 June 2015 - 02:40 PM

macosxnerd101, on 16 June 2015 - 02:12 PM, said:

Welcome to Dream.in.Code! />

Note that any code in your main() method gets executed. So the last statements in your main() method are the loop to prompt for the index of the company. You don't tell your program to do anything after the do-loop.

You have the salTot, salAvg, and totEmp methods. You might want to invoke them (after making them static methods first).

Yes yes...I think I see what your saying, thank you for the help I will work on that!