Academic Integrity: tutoring, explanations, and feedback — we don’t complete graded work or submit on a student’s behalf.

Please help me with this... import javax.swing.*; public class MinMaxSalary { pu

ID: 3533507 • Letter: P

Question

Please help me with this... import javax.swing.*; public class MinMaxSalary { public static void main(String args[]) { // Declare a named constant for array size here. double salary[10]; // Declare array here. double salary [] = new double [10]; // Use this integer variable as your loop index. int loopIndex; // Use this variable to store the salary input by user. double salary; // String version of salary input by user. String salaryString; // Use these variables to store the minimim and maximum salaries. double min, max; // Use these variables to store the total and the average. double total, average; // Write a loop to get salaries from user and assign to array. salaryString = JOptionPane.showInputDialog("Enter a salary: "); salary = Double.parseDouble(salaryString); // Assign value to array. // Assign the first element in the array to be the minimum and the maximum. min = salaries[0]; max = salaries[0]; // Start out your total with the value of the first element in the array. total = salaries[0]; // Write a loop here to access array values starting with numbers[1] // Within the loop test for minimum and maximum salaries. // Also accumulate a total of all salaries. // Calculate the average of the 10 salaries. // Print the salaries stored in the salaries array. // Print the maximum salary, minimum salary, and average salary. System.exit(0); } }

Explanation / Answer

import javax.swing.*;

import java.io.*;

import java.util.*;


public class MinMaxSalary

{

public static void main(String args[])

{

// Declare a named constant for array size here.

int size = 10;

// Declare array here.

double salary [] = new double [10];

// Use this integer variable as your loop index.

int loopIndex;

// Use this variable to store the salary input by user.

double Salary;

// String version of salary input by user.

String salaryString;

// Use these variables to store the minimim and maximum salaries.

double min, max;

// Use these variables to store the total and the average.

double total, average;

// Write a loop to get salaries from user and assign to array.

for(loopIndex=0;loopIndex<size;loopIndex++)

{

//JOptionPane J1 = new JOptionPane("Enter a salary: ");

//salaryString = J1.getValue().toString();

salaryString = JOptionPane.showInputDialog("Enter a salary: ");

  

Salary = Double.parseDouble(salaryString);

salary[loopIndex]=Salary;

}

// Assign value to array.

// Assign the first element in the array to be the minimum and the maximum.

min = salary[0];

max = salary[0];

// Start out your total with the value of the first element in the array.

total = salary[0];


for(loopIndex=1;loopIndex<size;loopIndex++)

{

total+=salary[loopIndex];

if(salary[loopIndex]>max)

max = salary[loopIndex];

if(salary[loopIndex]<min)

min = salary[loopIndex];

}

average = total/size;

for(loopIndex=0;loopIndex<size;loopIndex++)

System.out.println("Salary at index "+loopIndex+" = "+salary[loopIndex]);

System.out.println("Maximum salary = "+max);

System.out.println("Mainimum salary = "+min);

System.out.println("Average salary = "+average);

// Write a loop here to access array values starting with numbers[1]

// Within the loop test for minimum and maximum salaries.

// Also accumulate a total of all salaries.

// Calculate the average of the 10 salaries.

// Print the salaries stored in the salaries array.

// Print the maximum salary, minimum salary, and average salary.

System.exit(0);

}

}

Hire Me For All Your Tutoring Needs
Integrity-first tutoring: clear explanations, guidance, and feedback.
Drop an Email at
drjack9650@gmail.com
Chat Now And Get Quote