How To Make A Credit Card Finder On Java
utopian-io·@milliar·
0.000 HBDHow To Make A Credit Card Finder On Java
#### What Will I Learn? - You will learn how to make a credit card definer - You will learn how to use variables #### Requirements Write here a bullet list of the requirements for the user in order to follow this video tutorial. - Knowledge of coding - Eclipse and Java - Must have credit card or know how to generate one #### Difficulty - Basic #### Description Hello,in this tutorial i made a program that defines credit cards brand by its number.With this program you can easily find out your credit or bank cards type of brand. ``` import java.util.*; public class CreditCardFinder { public static void main(String[] args) { @SuppressWarnings("resource") Scanner input = new Scanner(System.in); System.out.println("Write your credit card number :"); String id = input.nextLine(); while (id.length() != 16) { System.out.println("Wrong Input.Credit Card Must Have 16 Numbers!"); id = input.nextLine(); } int x = sumAgain(id); int y = sum(id); if (isValid(x, y)) { System.out.println("Your Card Number Is True");type(id); } else { System.out.println("Your Card Is Out Of Use "); } } public static int sum(String myid) { int sum1 = 0; for (int i = myid.length() - 2; i >= 0; i -= 2) { int x = Character.getNumericValue(myid.charAt(i)); int y = x * 2; if (y >= 10) { int a = (y % 10) + 1; sum1 += a; } else sum1 += y; } return sum1; } public static int sumAgain(String myid) { int sum2 = 0; for (int i = myid.length() - 1; i >= 0; i -= 2) { int x = Character.getNumericValue(myid.charAt(i)); sum2 += x; } return sum2; } public static boolean isValid(int x,int y) { if ((x + y) %10 == 0) return true; return false; } public static void type(String myid) { switch(Character.getNumericValue(myid.charAt(0))) { case 3:System.out.println("Your Card Is ---- American Express");break; case 4:System.out.println("Your Card Is ---- Visa");break; case 5:System.out.println("Your Card Is ---- Master Card");break; default:System.out.println("Your Card Is ---- Discover Card");break; } } } ``` #### Video Tutorial https://www.youtube.com/watch?v=MBK6u_phnHQ&feature=youtu.be #### Curriculum - [Tutorial 1](https://utopian.io/utopian-io/@milliar/building-a-basic-game-on-java-jeclipse-course-2) - [Tutorial 2](https://utopian.io/utopian-io/@milliar/greengrocerer-automat-generation-on-java-jeclipse-course-1) <br /><hr/><em>Posted on <a href="https://utopian.io/utopian-io/@milliar/how-to-make-a-credit-card-finder-on-java">Utopian.io - Rewarding Open Source Contributors</a></em><hr/>