Your task is to create a program that can achieve the above requirements when given the students surname, first name and three digit postfix through CMD arguements
Sample run 1:
java InClass01_task01 Kandjeke Jenifer 003
Output: Good day Jenifer welcome to NUST.
Your email address is : jkandjeke@students.nust.na
Student number : KJEJEN003
Sample run 2:
java InClass01_task01 Kavezemba Terry 001
Output: Good day Terry welcome to NUST.
Your email address is : tkavezemba@students.nust.na
Student number : KZATER001
package nust;
public class NUST {
   public static void main(String[] args) {
    Â
    if (args.length < 2) {
      System.out.println("Invalid number");
      return;
    }
    String firstString = args[1];Â
    String lastString = args[0];Â
    String postfixString = args[2];
   Â
    int start_number = 0, end = lastString.length() - 1, mid = (lastString.length() % 2 == 0) ? lastString.length() / 2 : lastString.length() / 2;
    Â
    String number = lastString.charAt(start_number ) + "" + lastString.charAt(mid) + "" + lastString.charAt(end) + firstString.substring(0, 3)
        + postfixString;
    Â
    String email_given = firstString.charAt(0) + lastString + "@students.nust.na";
    System.out.println("Good day " + firstString + " welcome to NUST.");
    System.out.println("Your email address is : " + email_given.toLowerCase());
    System.out.println("Student number : " + number.toUpperCase());
  }
  Â
}
Comments
Leave a comment