Form a firstname.lastname@domain.se address, eliminating diacritics from a name I'm an amateur programmer who just started learning programming, my school gave me an assignment to create code that reads a surname and lastname from an input dialog box and then to edit those name in the format of "surname.lastname@nackademin.se" all of wich should be in lowercase letters and only letters of a-z since in sweden we sometimes use "å,ä,ö" in our names.
I have managed to do so, as you can see below but i was wondering if there was a simpler way to do this (perhaps by using less code).

import javax.swing.*;
public class Namn {
    public static void main(String[] arg) {
        char c = '.';
        String s = JOptionPane.showInputDialog(null, "Ange namn och efternamn");
        s = s.replaceAll("\\s{2,}", " ").trim();
        s = s.replace(' ', c);
        s = s.toLowerCase();
        s = s.replace('å', 'a');
        s = s.replace('ä', 'a');
        s = s.replace('ö', 'o');
        JOptionPane.showMessageDialog(null, s + "@nackademin.se");
        System.exit(0);
    }
}
You can chain replaces and you don't need to replace "n. spaces" -> " ", you can just replace them with a "." if you trim first

String s = JOptionPane.showInputDialog(null, "Ange namn och efternamn");
s = s.trim()
      .replaceAll("\\s{2,}", ".")
      .toLowerCase()
      .replace('å', 'a')
      .replace('ä', 'a')
      .replace('ö', 'o');
JOptionPane.showMessageDialog(null, s + "@nackademin.se");