-
Notifications
You must be signed in to change notification settings - Fork 0
/
Student.java
36 lines (30 loc) · 1.11 KB
/
Student.java
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
/*
Write a Function (with the appropriate types) that returns true if a given student is
"John Smith" with a student number of "js123" (otherwise return false).
*/
import java.util.Scanner;
public class Student {
private static final String firstName = "John";
private static final String lastName = "Smith";
public final String studentNumber = "js123";
public static String getFullName() {
return firstName + " " + lastName;
}
public String getCommaName() {
return lastName + ", " + firstName;
}
public static void main(String[] args) {
boolean checker = false;
Scanner kbd = new Scanner(System.in);
String userStudentNumber = getUserStudentNumber(kbd);
checker = (userStudentNumber.equals("js123")? checker = true: checker);
System.out.println(checker);
if (checker == true){
System.out.print(getFullName());
}
}
private static String getUserStudentNumber(Scanner kbd) {
System.out.print("Enter your student number: ");
return kbd.nextLine();
}
}