Hi, im having trouble to read from the keyboard the number of employees the user wants and in allowing the user to input up to 10 employees.

package application;
import dataStructures.*;
import java.util.Scanner;



     /* this is the list of employees * */
private LinkedList<String> employeeList; 

    /* constructor */

public TrainingCourses(){

employeeList = new LinkedList<String>();
    }

     /*1.
     * Main method,
      * allowing user to input employees up to 10
      * but first asking the user the number of employees
      */ 

public static void main(String[] args){

Scanner scan = new Scanner(System.in);
System.out.println("Enter the number of employees:  ");
  int n = scan.nextInt();

  employeeList.add(n)
    }

Recommended Answers

First of all, you are missing class declearation in your file!!!!

try using for loop to print out the values of the LinkedList? Also, why do u need the linkedlist if its just a number keep it only as int n then you could
System.out.println("The user entered number of employees: " …

Jump to Post

All 2 Replies

First of all, you are missing class declearation in your file!!!!

try using for loop to print out the values of the LinkedList? Also, why do u need the linkedlist if its just a number keep it only as int n then you could
System.out.println("The user entered number of employees: " +n);

I'm missing here only i actually have it in my file.

No the linked list is an employee list for a company. But first im asking the user how many employees does he want to put in the list, i can allow the user to input up to 10.

I'm lost and dont know how to make the number of employees that the user will enter equal to the linkedlist and at the same time allow up to 10 employees only.

Be a part of the DaniWeb community

We're a friendly, industry-focused community of 1.20 million developers, IT pros, digital marketers, and technology enthusiasts learning and sharing knowledge.