Guest User

Untitled

a guest
Feb 18th, 2018
78
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.75 KB | None | 0 0
  1. import java.util.Scanner;
  2.  
  3. /**
  4. This program computes the average and maximum of a set
  5. of input values.
  6. */
  7. public class DataAnalyzer
  8. {
  9. public static void main(String[] args)
  10. {
  11. Scanner in = new Scanner(System.in);
  12. DataSet data = new DataSet();
  13.  
  14. boolean done = false;
  15. while (!done)
  16. {
  17. System.out.print("Enter value, Q to quit: ");
  18. String input = in.next();
  19. if (input.equalsIgnoreCase("Q"))
  20. done = true;
  21. else
  22. {
  23. double x = Double.parseDouble(input);
  24. data.add(x);
  25. }
  26. }
  27.  
  28. System.out.println("Average = " + data.getAverage());
  29. System.out.println("Maximum = " + data.getMaximum());
  30. }
  31. }
Add Comment
Please, Sign In to add comment