Advertisement
Flaron

Udemy_19.LastDigitChecker

Sep 14th, 2019
356
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.58 KB | None | 0 0
  1. package lista.Alapok;
  2.  
  3. public class Main {
  4.  
  5. public static boolean hasSameLastDigit(int a, int b, int c) {
  6. if((a<10 || a>1000) || (b<10 || b>1000) ||(c<10 || c>1000)) return false;
  7. if ((a%10==b%10) || (a%10==c%10) || (b%10==c%10)) return true;
  8. else return false;
  9. }
  10. public static boolean isValid(int number) {
  11. while(number<10 || number>1000) return false;
  12. return true;
  13. }
  14.  
  15. public static void main(String[] args) {
  16. System.out.println(hasSameLastDigit(22, 33, 232));
  17. System.out.println(isValid(1230));
  18. }
  19. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement