//Author: Rayno Niemi //Course: 4002-220 //Topic: specialized input/output methods built on top of the Scanner class // import java.util.Scanner; /** * Extensions to the Scanner class * @author Bradley Weinstein * @version 1.1.1 */ public class MyScanner { private static Scanner myScan; public MyScanner() { myScan = new Scanner(System.in); } public char nextChar() { String in = myScan.next(); myScan.nextLine(); // flush buffer return in.charAt(0); } public char nextYN(char inYN) { char choice; System.out.print("Do you wish to enter another transaction (Y/N): "); choice = in.nextChar(); switch (choice) { case 'Y': choice = 'Y' break; case 'y': choice = 'Y'; break; case 'N': choice = 'N'; break; case 'n': choice = 'N'; break; default: System.out.print("\tnvalid input - choice must be either a Y or an N\n"); break; } return choice; } } //end class