Guest User

Untitled

a guest
Jun 25th, 2018
101
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.05 KB | None | 0 0
  1. // Checks if values are numbers only
  2. public static boolean NumbersOnly()
  3. {
  4. // Variables
  5. String Year;
  6. String amount;
  7.  
  8. char Yearchar;
  9. char Amountchar;
  10.  
  11.  
  12. // For loop for Year
  13. for (int i = 0; i < Year.length() ; i++)
  14. {
  15.  
  16. if (Character.isDigit(Yearchar))
  17. { System.out.println(Yearchar + " is numeric.");
  18. return true;
  19. } else
  20. { System.out.println(Yearchar + " is a letter.");
  21. return false;
  22.  
  23. }
  24. }
  25.  
  26. for (int i = 0; i < amount.length() ; i++)
  27. {
  28.  
  29. if (Character.isDigit(Amountchar))
  30. { System.out.println(Amountchar + " is numeric.");
  31. return true;
  32. } else
  33. { System.out.println(Amountchar + " is a letter.");
  34. return false;
  35.  
  36. }
  37. }
  38.  
  39.  
  40. } //end of NumbersOnly method
  41.  
  42.  
  43. // 'get' Input amount method
  44. public static boolean InputAmount()
  45. {
  46. Scanner keyboard = new Scanner(System.in);
  47. // Variables
  48. char amountchar;
  49. String Amount;
  50.  
  51. System.out.print("Enter the amount(9999): ");
  52. Amount = keyboard.nextLine();
  53. amountchar = Amount.charAt(0);
  54.  
  55.  
  56. while (NumbersOnly(String Amount) = true)
  57. {
  58. System.out.println("Error!");
  59.  
  60.  
  61. }
  62. }// End of InputAmount
Add Comment
Please, Sign In to add comment