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;

Database System Concepts
7th Edition
ISBN:9780078022159
Author:Abraham Silberschatz Professor, Henry F. Korth, S. Sudarshan
Publisher:Abraham Silberschatz Professor, Henry F. Korth, S. Sudarshan
Chapter1: Introduction
Section: Chapter Questions
Problem 1PE
icon
Related questions
Question

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
Transcribed Image Text: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
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
Transcribed Image Text: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
Expert Solution
steps

Step by step

Solved in 2 steps

Blurred answer
Knowledge Booster
Types of Loop
Learn more about
Need a deep-dive on the concept behind this application? Look no further. Learn more about this topic, computer-science and related others by exploring similar questions and additional content below.
Similar questions
Recommended textbooks for you
Database System Concepts
Database System Concepts
Computer Science
ISBN:
9780078022159
Author:
Abraham Silberschatz Professor, Henry F. Korth, S. Sudarshan
Publisher:
McGraw-Hill Education
Starting Out with Python (4th Edition)
Starting Out with Python (4th Edition)
Computer Science
ISBN:
9780134444321
Author:
Tony Gaddis
Publisher:
PEARSON
Digital Fundamentals (11th Edition)
Digital Fundamentals (11th Edition)
Computer Science
ISBN:
9780132737968
Author:
Thomas L. Floyd
Publisher:
PEARSON
C How to Program (8th Edition)
C How to Program (8th Edition)
Computer Science
ISBN:
9780133976892
Author:
Paul J. Deitel, Harvey Deitel
Publisher:
PEARSON
Database Systems: Design, Implementation, & Manag…
Database Systems: Design, Implementation, & Manag…
Computer Science
ISBN:
9781337627900
Author:
Carlos Coronel, Steven Morris
Publisher:
Cengage Learning
Programmable Logic Controllers
Programmable Logic Controllers
Computer Science
ISBN:
9780073373843
Author:
Frank D. Petruzella
Publisher:
McGraw-Hill Education