Note that there are some explanatory texts on larger screens.

plurals
  1. POCreating an email and username from the users name and surname? (Java)
    primarykey
    data
    text
    <p>Right now I am making a small program which should create an email adress and username out of the users actual name. For example, Peter Anderson types his first and last name in two separate text fields, and the program should then return a username and an email adress in two separate textfields, once you press the save button. For example, Peter Anderson gets the username "a13petand" and the email adress "a13petand@test.com" a = autumn, 13 = 2013. It should only take the first 3 letters from first &amp; last name. It should then append the first name, last name, username and email adress to the text area. This is how my code currently looks like;</p> <pre><code>package test5; import javax.swing.JOptionPane; public class Test5 extends javax.swing.JFrame { String[][] Users = new String[20][4]; int counter; public Test5() { initComponents(); } private void savebtnActionPerformed(java.awt.event.ActionEvent evt) { if (counter &lt; Users.length) { Users[counter][0] = Firstnametf.getText(); Users[counter][1] = Lastnametf.getText(); Users[counter][2] = Usernametf.getText(); Users[counter][3] = Emailtf.getText(); jTextArea1.append(Users[counter][0] + ", " + Users[counter][1] + ", " + Users[counter][2] + ", " + Users[counter][3] + "\n"); counter++; } else { JOptionPane.showMessageDialog(null, "The array is full!"); counter = Users.length; } } </code></pre> <p>How should I continue from here? How do I make it generate "a13" and then take the first 3 letters in the first and last name? That is my main problem. All I know is that I should use the String class method substring to pick the first 3 letters out of first &amp; last name. And then use the Calendar class to get the correct year. But I don't know how to make it work with my current code, which is the problem. </p>
    singulars
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    plurals
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload