package readtwopostiveinteger;
import java.util.*;
import java.io.*;
public class ReadTwoPostiveInteger {
private static final int numAttempts=5;
private static int posInt;
public static void main(String[] args) {
int i = 0;
System.out.println("Enter two postive integers,one at a time, # of Attemps Remaining:"+numAttempts);
Scanner keyb = new Scanner(System.in);
for(i=1; i<=numAttempts-1; i++) {
try { posInt = keyb.nextInt();{
if (posInt>0)
System.out.println("Correct");}
if (posInt<=0) throw new InputMismatchException();
}
catch(InputMismatchException ime){
System.out.println("Your Input was not a positive integer");
if (i== numAttempts) System.out.println ("sorry");
else System.out.println("Enter a postive integer,#of attemps remaining:" +numAttempts);
continue;}
}
}
}