Answer to Question #254548 in Java | JSP | JSF for Mike

Question #254548

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 arguements

1
Expert's answer
2021-10-21T07:23:05-0400


public class App {
	/**
	 * The start point of the program
	 * 
	 * @param args
	 */
	public static void main(String[] args) {
		if (args.length == 3) {
			String surname = args[0];
			String firstName = args[1];
			String threeDigitPostfixNumber = args[2];


			// 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
			String emailAddress = firstName.toLowerCase().charAt(0) + surname.toLowerCase() + "@students.nust.na";
			// 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.
			int mid=surname.length()/2;
			String number = surname.toUpperCase().substring(0, 1) + surname.toUpperCase().charAt(mid)
					+ surname.toUpperCase().charAt(surname.length()-1)+ firstName.toUpperCase().substring(0, 3) + threeDigitPostfixNumber;


			System.out.println("Your email address is: " + emailAddress);
			System.out.println("Student number: " + number);
		} else {
			System.out.println("Wrong CMD arguements");
		}


	}


}

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