-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathEnrolmentAdvanced.java
More file actions
45 lines (37 loc) · 1.58 KB
/
EnrolmentAdvanced.java
File metadata and controls
45 lines (37 loc) · 1.58 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
import java.util.Scanner;
import java.util.Random;
/*
* Asks for your email and checks if it is valid email
* Ask for your year group and checks if it is valid
* Asks if the user happy with the data entered, if yes, then it creates a student ID
*/
public class EnrolmentAdvanced{
public static void main(String[] args){
Scanner scanner = new Scanner(System.in);
System.out.print("Enter your email: ");
String email = scanner.nextLine();
while(!email.contains("@")){
System.out.print("Not valid email. Enter your email: ");
email = scanner.nextLine();
}
System.out.print("Enter your year group: ");
String yearGroup = scanner.nextLine();
while(!yearGroup.equals("U6") && !yearGroup.equals("L6")){
System.out.print("Wrong year group. Enter your year group: ");
yearGroup = scanner.nextLine();
}
String randomID = "E" + new Random().nextInt(100000);
System.out.print("Are you happy whith the data entered (yes/no): ");
String happy = scanner.nextLine();
while(!happy.equalsIgnoreCase("yes") && !happy.equalsIgnoreCase("no")){
System.out.print("Are you happy whith the data entered (yes/no): ");
happy = scanner.nextLine();
}
if(happy.equalsIgnoreCase("yes")){
System.out.println("Email: " + email);
System.out.println("Year group: " + yearGroup);
System.out.println("StudentID: " + randomID);
}
scanner.close();
}
}