Salary > Compile Undo Cut Соpy Paste Find. Close Source Code // The program should prompt the user with employee names, like: // "What is the salary of Xiaoxing?" for(int i = 0; i<3; i++){ System.out.println("What is the salary of"+names[i]); salaries[i] = input.nextDouble(); // Then, modify the statements below to print out the average salary of all employees // and the NAME of the employee with the highest salary // You should invoke the methods index0fHighest(), and getArrayAverage(). // The average number should have two decimal points System.out.printf("The average salary is:%.2f\n",getArrayAverage(salaries)); System.out.println("The employee with the highest salary is:"+names[index0fHighest(salaries) ]); incompatible types: double[] cannot be converted to int[] private static double getArrayAverage(double[] input){ double sum = 0; for (double val:input) sum+=val; return sum/input.length; private static int index0fHighest(int[] input){ int highestIndex=0; for (int i =0;iinput[highestIndex]) highestIndex = i; return highestIndex;
Types of Loop
Loops are the elements of programming in which a part of code is repeated a particular number of times. Loop executes the series of statements many times till the conditional statement becomes false.
Loops
Any task which is repeated more than one time is called a loop. Basically, loops can be divided into three types as while, do-while and for loop. There are so many programming languages like C, C++, JAVA, PYTHON, and many more where looping statements can be used for repetitive execution.
While Loop
Loop is a feature in the programming language. It helps us to execute a set of instructions regularly. The block of code executes until some conditions provided within that Loop are true.
I want help fixing this error.
![Salary x
Compile
Undo
Cut
Соpy
Paste
Find...
Close
Source Code
import java.util.Scanner;
/**
* Midterm programming question
* Provided below is an incomplete Java Program
* Follow the instructions in the comments to complete this program
* A sample run results will be provided separately
*
*/
public class Salary
{
public static void main(String[] args){
String[] names
double[] salaries
Scanner input
new String[3];
new double[3];
= new Scanner(System.in);
%3D
// First, using loop to get 3 employee names from the user, and save them in the array "names"
// Hint: to get String values, use input.nextLine() method
for(int i = 0; i< 3; i++) {
System.out.println("Please enter 3 employee names");
names[i]=input.nextLine();
%3D
// Next, using loop to get the salaries of the 3 employees, and save them in the array "salaries"
// The program should prompt the user with employee names, like:
// "What is the salary of Xiaoxing?"
for(int i = 0; i<3; i++){
System.out.println("What is the salary of"+names[i]);
salaries[i] = input.nextDouble();
}
// Then, modify the statements below to print out the average salary of al1 employees
// and the NAME of the employee with the highest salary
// You should invoke the methods index0fHighest(), and getArrayAverage().
saved
Errors: 1](/v2/_next/image?url=https%3A%2F%2Fcontent.bartleby.com%2Fqna-images%2Fquestion%2F6bf2943f-700f-43bc-a328-58066267f331%2Fa5a1d191-0681-41f0-b6cf-a8d906844b3a%2F57cs19d_processed.png&w=3840&q=75)
![Salary x
Compile
Undo
Cut
Сopy
Paste
Find...
Close
Source Code
// The program should prompt the user with employee names, like:
// "What is the salary of Xiaoxing?"
for (int i
System.out.println("What is the salary of"+names[i]);
salaries[i] = input.nextDouble();
0; i<3; i++) {
// Then, modify the statements below to print out the average salary of all employees
// and the NAME of the employee with the highest salary
// You should invoke the methods index0fHighest(), and getArrayAverage().
// The average number should have two decimal points
System.out.printf("The average salary is:%.2f\n",getArrayAverage (salaries));
System.out.println("The employee with the highest salary is:"+names[index0fHighest(salaries)]);
incompatible types: double[] cannot be converted to int[]
}
private static double getArrayAverage (double[] input){
double sum
:%3B
for (double val:input)
sum+=val;
return sum/input.length;
private static int index0fHighest(int[] input){
int highestIndex=0%;
for(int i =0;i<input.length;i++)
if(input[i]>input[highestIndex])
highestIndex
return highestIndex;
}
i;
스
saved
Errors: 1](/v2/_next/image?url=https%3A%2F%2Fcontent.bartleby.com%2Fqna-images%2Fquestion%2F6bf2943f-700f-43bc-a328-58066267f331%2Fa5a1d191-0681-41f0-b6cf-a8d906844b3a%2Fekrudkm_processed.png&w=3840&q=75)

Step by step
Solved in 2 steps









