Answer to Question #240989 in Java | JSP | JSF for Frans

Question #240989

An University would like to introduce an automated student number and email generation system. The system takes into consideration the following: a) To generate the student number it takes three letters(the first, middle and last letter) of the student’s surname and adds it to the first three letters from the first name, then finally adds a three digit postfix number. b) To generate the email is quite easy it just takes the first letter from the first name and adds it to the surname , then it adds the @students.nust.na postfix 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 arguments.


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


run 2:

java InClass01_task01 Kavezemba Terry 001


Output: Good day Terry welcome to NUST.

Your email address is : tkavezemba@students.nust.na


1
Expert's answer
2021-09-23T17:47:39-0400
import java.util.Scanner;
public class Main
{
	public static void main(String[] args) {
	    Scanner input=new Scanner(System.in);
	    System.out.println("Enter the first name");
	    String First=input.next();
	    System.out.println("Enter the second name");
	    String Second=input.next();
	    char n=Second.charAt(0);
	    System.out.print("Enter a 3 digit interger: ");
	    int num=input.nextInt();
	    char ch=First.charAt(0);
	    
	    
	     int len = Second.length();
	     int last=len-1;
	     int middle = len / 2;
	     System.out.print("Good day "+ First+" welcome to NUST.");
	     System.out.print("\nYour email address is: "+ch+Second+"@students.nust.na");
	     System.out.print("\nStudent number: "+Second.charAt(0)+Second.charAt(middle)+Second.charAt(last)+First.charAt(0)+First.charAt(1)+First.charAt(2)+num);
	    
	  
}
}

Need a fast expert's response?

Submit order

and get a quick answer at the best price

for any assignment or question with DETAILED EXPLANATIONS!

Comments

No comments. Be the first!

Leave a comment

LATEST TUTORIALS
New on Blog
APPROVED BY CLIENTS