Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- /**
- * @author Wookjin Kim
- */
- import java.util.Scanner;
- public class Max
- {
- public static void main(String[] args)
- {
- Scanner integer = new Scanner (System.in);
- // make a loop here and break after it displays the line when 0 is entered. insert the body here.
- System.out.println("Enter a positive integer or 0 to terminate the run: ");
- int number = integer.nextInt();
- int counter = 0;
- int max = 1;
- if (number > max)
- {
- max = number;
- counter = 1;
- System.out.println("Enter a positive integer or 0 to terminate the run: ");
- }
- if (number == max)
- {
- counter++;
- System.out.println("Enter a positive integer or 0 to terminate the run: ");
- }
- else
- {
- System.out.println("The max number is " + max + " and it was insterted " + counter + " times.");
- }
- }
- }
Add Comment
Please, Sign In to add comment