-1

I have a piece of code, I ask the user to put the number of Livre he wants to create, and then I iterate according to the number. when I arrive to scan the (Livre) fields, I got an error. when I scan by:

String nom = scanner.next();

for example, I type "Algorithme status" my code assigns "Algorithme" to variable nom

and assign "status" to the variable ref

here's the code:

System.out.println("how many Livre you want to add?");
            numIter = scanner.nextInt();
            for (int i = 0 ; i < numIter ; i++) {
                System.out.println("Nom de livre:");
                String nom = scanner.next();
                System.out.println("Reference:");
                String ref = scanner.next();
                System.out.println("Quota:");
                int quota = scanner.nextInt();
                System.out.println("Type:");
                String type = scanner.next();
                System.out.println("Cote:");
                String cote = scanner.next();

                Livre l = new Livre(ref, quota, true, type, cote, nom);

                Media.mediaList.add(l);
            }

I want, when typing "Algorithme status", to assign all this string only to the variable "nom"

0 Answers0