Question

In: Computer Science

JAVA StudentId: Consist of the first two characters of the student's first name, student's birth year,...

JAVA

StudentId: Consist of the first two characters of the student's first name, student's birth year, and the last two characters of the last name. For instance, if the student full name is John Doe and birthyear is 1995, then the id will be Jo1995oe. Birthday is using GregorianCalendar.

String firstname

String lastname

GregorianCalendar birthday

Solutions

Expert Solution

import java.util.Calendar;
import java.util.GregorianCalendar;

class Student {
   private String ID;
   private String fname;
   private String lname;
   private GregorianCalendar birthday;

   public Student(String aFname, String aLname, GregorianCalendar aBirthday) {
       super();
       fname = aFname;
       lname = aLname;
       birthday = aBirthday;
       //generating ID with 2 chars from first name and appending year and fetching last 2 chars from lname
       ID = fname.substring(0, 2) + birthday.get(Calendar.YEAR) + lname.substring(lname.length() - 2);
   }

   public String getID() {
       return ID;
   }

   public String getFname() {
       return fname;
   }

   public String getLname() {
       return lname;
   }

   public GregorianCalendar getBirthday() {
       return birthday;
   }

   @Override
   public String toString() {
       return "ID : " + ID + ", fname : " + fname + ", lname : " + lname;
   }

}

public class TestStudentID {
   public static void main(String[] args) {
       GregorianCalendar birth = new GregorianCalendar(1995, 1, 1);
       Student s = new Student("John", "Doe", birth);
       System.out.println(s);
   }
}

Note : Please comment below if you have concerns. I am here to help you

If you like my answer please rate and help me it is very Imp for me


Related Solutions

Create a database with two tables as follows:- Students - StudentID, Name, Program FeePayment - StudentID,...
Create a database with two tables as follows:- Students - StudentID, Name, Program FeePayment - StudentID, Date, Description, Amount 1. Create a stored procedure that receives all the details of a student including fees and proceeds to insert insert the student details into the student details and the fee payment into the FeePayment table. All the operations should be done within a single transaction in a stored procedure. Note that the stored procedure works like a function that receives parameters....
This question concerns writing a Student class to model a student's name, composed of a first...
This question concerns writing a Student class to model a student's name, composed of a first name, middle name and last name. The Student class should meet the following specification: Class Student A Student object represents a student. A student has a first name, middle name and last name. Methods public void setNames(String first, String middle, String last) // Set the first, middle and last names of this Student object. public String getFullName() // Obtain the full name of this...
Write a java code that first discards as many whitespace characters as necessary until the first...
Write a java code that first discards as many whitespace characters as necessary until the first non-whitespace character is found. Then, starting from this character, takes an optional initial plus or minus sign followed by as many numerical digits as possible, and interprets them as a numerical value. The string can contain additional characters after those that form the integral number, which are ignored and have no effect on the behavior of this function. If the first sequence of non-whitespace...
Write a java code that first discards as many whitespace characters as necessary until the first...
Write a java code that first discards as many whitespace characters as necessary until the first non-whitespace character is found. Then, starting from this character, takes an optional initial plus or minus sign followed by as many numerical digits as possible, and interprets them as a numerical value. The string can contain additional characters after those that form the integral number, which are ignored and have no effect on the behavior of this function. If the first sequence of non-whitespace...
Create a table ‘StudentInfo’ with following fields: ID First Name Last Name SSN Date of Birth...
Create a table ‘StudentInfo’ with following fields: ID First Name Last Name SSN Date of Birth Create a table ‘ClassInfo’ table: ID Class Name Class Description Create a table ‘RegisteredClasses’ table: StudentID ClassID The RegisteredClasses table should have a foreign key relationship to StudentInfo and ClassInfo tables for the respective IDs. Also the IDs in StudentInfo and ClassInfo need to be primary keys. When you submit the file your email should also contain the following SQL Queries: Query to show...
#promt the user to enter student name for i in range(0, 3): print ("Enter student's first...
#promt the user to enter student name for i in range(0, 3): print ("Enter student's first and last name") #variable for name name = input() #prompt the user to enter number of book purchased print ("Enter the number of book the student purchased this month") #varibale for number of book book_number = input() book_number = int (book_number) #point = int (point) if (book_number <=0): points = 0 elif (book_number <=3): points = 5 elif (book_number <=6): points = 10 elif...
create a python program that ask for a name and birth year separated by a comma....
create a python program that ask for a name and birth year separated by a comma. the program should keep prompting until the user inputs 'quit'. print the dictionary containing the key value pair name:year in the same order they were inputted. print the name and birth year on a single line for each of the entries. finally print the dictionary with the key value paris swapped and sorted by birth year. from youngest to oldeest.
Using jGRASP, write a Java program named LastnameFirstname10.java, using your last name and your first name,...
Using jGRASP, write a Java program named LastnameFirstname10.java, using your last name and your first name, that does the following: Create two arrays that will hold related information. You can choose any information to store, but here are some examples: an array that holds a person's name and an array that hold's their phone number an array that holds a pet's name and an array that holds what type of animal that pet is an array that holds a student's...
Using jGRASP, write a Java program named LastnameFirstname09.java, using your last name and your first name,...
Using jGRASP, write a Java program named LastnameFirstname09.java, using your last name and your first name, that does the following: Declare an array reference variable called myFavoriteSnacks for an array of String type. Create the array so that it is able to hold 10 elements - no more, no less. Fill the array by having each array element contain a string stating one of your favorite foods/snacks. Note: Only write the name of the snack, NO numbers (i.e. Do not...
Using jGRASP, write a Java program named LastnameFirstname11.java, using your last name and your first name,...
Using jGRASP, write a Java program named LastnameFirstname11.java, using your last name and your first name, that does the following: Defines a method called generateNums. This method will create an array of size x, fill it with random numbers between y and z, then return the array. When you call the method, you must specify the size of the array (x), the beginning of your random number range (y), and the ending of your random number range (z). Defines a...
ADVERTISEMENT
ADVERTISEMENT
ADVERTISEMENT