Write a program that will allow the user to enter series of numbers and will giv
ID: 3697149 • Letter: W
Question
Write a program that will allow the user to enter series of numbers and will give some useful statistics about the numbers. This program should be composed of two events: Enter Numbers Button Click – Allow the user to enter series of numbers using input dialog boxes. Use a loop and add the numbers to the listBox as they are input,. Prompt the user to enter”x” to stop adding numbers. Compute Statistics Button Click – Compute the following statistics from the numbers in the listBox: Count, Sum, Average, Minumum, Maximum, Count of even #s, Count of negative #s
Explanation / Answer
import java.util.Scanner; public class exc5 { public static void main (String[] args) { System.out.println("Write a list of nonnegative integers, each seperated by a space. To signal the end of the list"); Scanner keyboard = new Scanner (System.in); keyboard.useDelimiter(" | "); int count = 0,counteven=0,countnegative=0 ; int sum = 0; int max = 0; int min = max; double average = 0; boolean notNull = true; while(notNull == true) { int getInt = keyboard.nextInt(); if(getInt < 0) { notNull = false; countnegative++; } else { if(getInt > max) { max = getInt; } if(getInt%2=0) { System.out.println("Minimum = " + min); counteven++; } if(getIntRelated Questions
Hire Me For All Your Tutoring Needs
Integrity-first tutoring: clear explanations, guidance, and feedback.
Drop an Email at
drjack9650@gmail.com
drjack9650@gmail.com
Navigate
Integrity-first tutoring: explanations and feedback only — we do not complete graded work. Learn more.