Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- // Checks if values are numbers only
- public static boolean NumbersOnly()
- {
- // Variables
- String Year;
- String amount;
- char Yearchar;
- char Amountchar;
- // For loop for Year
- for (int i = 0; i < Year.length() ; i++)
- {
- if (Character.isDigit(Yearchar))
- { System.out.println(Yearchar + " is numeric.");
- return true;
- } else
- { System.out.println(Yearchar + " is a letter.");
- return false;
- }
- }
- for (int i = 0; i < amount.length() ; i++)
- {
- if (Character.isDigit(Amountchar))
- { System.out.println(Amountchar + " is numeric.");
- return true;
- } else
- { System.out.println(Amountchar + " is a letter.");
- return false;
- }
- }
- } //end of NumbersOnly method
- // 'get' Input amount method
- public static boolean InputAmount()
- {
- Scanner keyboard = new Scanner(System.in);
- // Variables
- char amountchar;
- String Amount;
- System.out.print("Enter the amount(9999): ");
- Amount = keyboard.nextLine();
- amountchar = Amount.charAt(0);
- while (NumbersOnly(String Amount) = true)
- {
- System.out.println("Error!");
- }
- }// End of InputAmount
Add Comment
Please, Sign In to add comment