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

If input is 50, 55, 60, 0, your output should be: //Read integers and findthe to

ID: 3618373 • Letter: I

Question

If input is 50, 55, 60, 0, your output should be:

//Read integers and findthe total and average of input values, not countingzeros                               
import java.util.*;

importjavax.swing.JOptionPane;
public class ReadIntegers {

public static voidmain(String[] args){
Scanner keyboard = new Scanner(System.in);
      
int input = 1;
Vector<Integer> numbers = newVector<Integer>();
String s;
double avg = 0, sum = 0;
           
while(input != 0){
      s =JOptionPane.showInputDialog("Please Enter in a number:");
      input = Integer.parseInt(s);
      if(input != 0){
        numbers.add(input);
      }
}
           
Collections.sort(numbers);
           
for(int i = 0; i < numbers.size(); i++)
     sum += numbers.get(i);
           
avg = sum/numbers.size();
           
JOptionPane.showMessageDialog(null, "The total is: " +sum
     + " The average is: " + avg
     + " The largest is: " +numbers.get(numbers.size()-1)
     + " The smallest is: " +numbers.get(0));
           
}

}

Explanation / Answer

please rate - thanks //Read integers and find the total and average of input values, notcountingzeros                               import java.util.*; import javax.swing.JOptionPane; public class ReadIntegers { public static void main(String[] args){ Scanner keyboard = new Scanner(System.in);      int input = 1; Vector numbers = newVector(); String s; double avg = 0, sum = 0;           while(input != 0){       s =JOptionPane.showInputDialog("Please Enter in a number:");       input = Integer.parseInt(s);       if(input != 0){         numbers.add(input);       } }           Collections.sort(numbers);           for(int i = 0; i
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