Advertisement
nov0

Z5_OcuranceOfGreaterNumber

May 30th, 2015
238
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Java 0.50 KB | None | 0 0
  1. import java.util.Scanner;
  2.  
  3. public class Z5_NizBr {
  4.  
  5.     public static void main(String[] args) {
  6.         Scanner input = new Scanner(System.in);
  7.         int num = 0;
  8.         int temp;
  9.         int count = 0;
  10.  
  11.         do {
  12.             System.out.println("Enter a number: ");
  13.             temp = input.nextInt();
  14.             if (temp > num) {
  15.                 num = temp;
  16.                 count = 1;
  17.             } else if (num == temp) {
  18.                 count++;
  19.             }
  20.  
  21.         } while (temp != 0);
  22.  
  23.         System.out.println("Greater number is " + num + " and has occurred "
  24.                 + count + " times");
  25.     }
  26. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement