rendered paste body public double nextDoublePos(String prompt)
{
double amount = 0;
try
{
//read first value
System.out.print( prompt );
amount = myScan.nextDouble();
myScan.nextLine(); //flush internal buffer
//keep reading if not positive
while( amount <= 0.0 )
{ //invalid withdraw
System.out.println("\tError: input must be > 0");
//read next input
System.out.print(prompt);
amount = myScan.nextDouble();
myScan.nextLine();
}
}
catch(InputMismatchException ime)
{
System.out.println("Input mismatch. Please input a a ");
System.exit(1);
}
catch(Exception e)
{
System.out.print("General exception. Exiting");
System.exit(1);
}
return amount;
}