Guest User

Untitled

a guest
Feb 18th, 2018
77
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.93 KB | None | 0 0
  1. /**
  2. * @author Wookjin Kim
  3. */
  4. import java.util.Scanner;
  5.  
  6. public class Max
  7. {
  8. public static void main(String[] args)
  9. {
  10. Scanner integer = new Scanner (System.in);
  11. // make a loop here and break after it displays the line when 0 is entered. insert the body here.
  12. System.out.println("Enter a positive integer or 0 to terminate the run: ");
  13. int number = integer.nextInt();
  14. int counter = 0;
  15. int max = 1;
  16.  
  17. if (number > max)
  18. {
  19. max = number;
  20. counter = 1;
  21. System.out.println("Enter a positive integer or 0 to terminate the run: ");
  22. }
  23.  
  24. if (number == max)
  25. {
  26. counter++;
  27. System.out.println("Enter a positive integer or 0 to terminate the run: ");
  28. }
  29.  
  30. else
  31. {
  32. System.out.println("The max number is " + max + " and it was insterted " + counter + " times.");
  33. }
  34. }
  35. }
Add Comment
Please, Sign In to add comment