Hello.
I need help with a program in Java im trying to make.
Its supposed to build a program like the one the Quebec Ministry Of Education uses to give studends their codes.
The thing is that after typing personal info in the program, the program should build the code from the name, last name, day month and year of birth, sex and other stuff.
But i cant figure out how to print a leading zero when the day or month are under 10 (this must be only when the day or month are under 10)
And im also supposed to make that if the user chooses sexe as Feminin, it should add 50 to the month value.
This is my code (sorry its in french , ill put some comments so u can get around)
Code:
import java.util.*;
public class TP3B {
public static void main(String args[] ) {
Scanner clavier = new Scanner(System.in);
System.out.print("Saisir le nom: "); //Last name
String nom = clavier.next();
nom = nom.toUpperCase();
System.out.print("Saisir le prenom: "); //Name
String prenom = clavier.next();
prenom = prenom.toUpperCase();
System.out.print("Saisir le jour de naissance: "); //Day of Birth
int jourNaissance = clavier.nextInt();
if (jourNaissance < 10){
}
System.out.print("Saisir le mois de naissance: "); //Month of birth
String moisNaissance = clavier.next();
System.out.print("Saisir l'annee de naissance: "); //Year of Birth
String anneeNaissance = clavier.next();
System.out.print("Est-il Homme (O/N): "); // Are you a man?
String sexe = clavier.next();
System.out.println("Voice votre code permanent: " + nom.substring(0, 3) + prenom.substring(0, 1) + moisNaissance + anneeNaissance.substring(2, 4) + doubles);
Thank you again for the help!
Bookmarks