Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- package one;
- import java.util.Scanner;
- public class JavaBikes1 {
- public static void main(String[] args) {
- // TODO Auto-generated method stub
- System.out.println("WELCOME");
- Scanner input = new Scanner(System.in);
- System.out.println("Press 1 for \"login\" and 2 for \"create new account\"");
- int menuChoice = input.nextInt();
- if (menuChoice == 2) {
- System.out.print("Enter your first and last name: ");
- String name = input.nextLine();
- System.out.print("Enter your postal code: ");
- int postCode = input.nextInt();
- while (postCode > 2501 || postCode < 1000) {
- System.out.println("Please enter a valid 4 digit postal code for the Copenhagen area: ");
- int postCodes = input.nextInt();
- }
- System.out.print("Enter your phone number: ");
- int phoneNumber = input.nextInt();
- String phoneNumber1 = Integer.toString(phoneNumber);
- int length = phoneNumber1.length();
- while (length != 8) {
- System.out.println("Please enter a valid 8 digit phone number");
- phoneNumber = input.nextInt();
- }
- System.out.print("Enter your date of birth (i.e. mm-dd-yyyy): ");
- String dateOfBirth = input.nextLine();
- System.out.println("Enter your CPR (i.e. XXXXXX-XXXX): ");
- int cpr = input.nextInt();
- //while ( true ) {
- //int i = 0;
- //char digit = dateOfBirth.charAt(i);
- //Character.isDigit(digit);//
- String username = createUsername(name);
- System.out.print("Enter your desired password (max 8 numbers): ");
- int password = input.nextInt();
- System.out.println("Your username is " + username + " and your password is " + password);
- }
- else if (menuChoice == 1) {
- System.out.print("Enter your username: ");
- String usernameAttempt = input.nextLine();
- System.out.print("Enter your password: ");
- int passwordAttempt = input.nextInt();
- while (usernameAttempt != username || passwordAttempt != password) {
- System.out.print("Wrong username or password. Try again: ");
- System.out.print("Enter your username: ");
- usernameAttempt = input.nextLine();
- System.out.print("Enter your password: ");
- passwordAttempt = input.nextInt();
- }
- }
- }
- // Creates method for generating username
- public static String createUsername(String name) {
- String[] parts = name.split(" ");
- String firstName = parts[0];
- String lastName = parts[1];
- int number = (int)(Math.random() * 101);
- //int lastName1 = Integer.parseInt(lastName);
- String username = "lastName" + "number";
- return username;
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement