fork(1) download
  1. import java.util.Scanner;
  2.  
  3. class Ideone {
  4. public static void main(String[] args) {
  5. Scanner input = new Scanner(System.in);
  6. int number;
  7. int max = 0;
  8. int min = 0;
  9. int countMax = 0;
  10. int countMin = 0;
  11.  
  12. for (int x = 0; x < 3; x++) {
  13. System.out.print("Give me an integer: ");
  14. number = input.nextInt();
  15.  
  16. if (x == 0 || number > max) {
  17. countMax = 1;
  18. max = number;
  19. } else if (number == max) {
  20. countMax++;
  21. }
  22. if (x == 0 || number < min) {
  23. countMin = 1;
  24. min = number;
  25. } else if (number == min) {
  26. countMin++;
  27. }
  28. }
  29.  
  30. System.out.println("Highest value: " + max);
  31.  
  32. System.out.println("Count of highest values: " + countMax);
  33.  
  34. System.out.println("Lowest value: " + min);
  35.  
  36. System.out.println("Count of lowest values: " + countMin);
  37. }
  38. }
Success #stdin #stdout 0.06s 4386816KB
stdin
10 
10 
20
stdout
Give me an integer: Give me an integer: Give me an integer: Highest value: 20
Count of highest values: 1
Lowest value: 10
Count of lowest values: 2