

import java.io.FileNotFoundException;
import java.io.File;
import java.util.*; 
import java.text.DecimalFormat;

public class SeatingChartBuilder
   {
   
   static Scanner sc = new Scanner(System.in); //SC1
   public static void main (String args [])
      {
      ArrayList<Students> students = new ArrayList<Students>();   //SC2
      System.out.println("How many test students do you want to create?");
      int nameCount = integerInputManager(); 
      
        //SC3
      String [] allNames ={"Walter","Jones","Rose","Wilson" ,"Jack", "Rodriguez" , "Elizabeth" , "Smith", "Earl", "Carter", "Linda", "Ward", "Christopher", 
         "Turner", "Martin", "Murphy", "Betty", "Garcia", "Shawn", "Taylor","Sean", "Simmons", "Joshua", "Evans", "Norma", "Mitchell", "Brenda", "Johnson", "Donna", 
         "Clark", "Irene", "Diaz","Marilyn", "Coleman","Arthur", "Collins","Henry", "Hall","Howard", "Robinson","Jerry", "Green","Maria", "Price", "Evelyn", "Bell", 
         "Janet", "Moore", "Susan", "Foster"};
         
      students = setStudents(students, allNames, nameCount);
      printStudents(students);
   
      }

   //This will create the random students
   private static ArrayList<Students> setStudents(ArrayList<Students> stuList, String [] allNames, int nc)
      {
      Random rand = new Random();  //SC6
      Students s;
      ArrayList<Students> students = stuList;
      DecimalFormat df = new DecimalFormat("#.00");  //SC7
      int nameCount = nc;
      double gpa;
      int grade;
      String fn; String ln; 
      for(int i =0; i<nameCount; i++)  //SC8
         {
         
         do{
         
            fn = allNames[rand.nextInt(allNames.length)];
            ln = allNames[rand.nextInt(allNames.length)];
            }while(fn.equals(ln)); //SC8
         grade = rand.nextInt(4)+9; //SC9
         double tempGPA = rand.nextDouble()*3.0 + 1.0; //SC10
         String  tempString =df.format(tempGPA); //SC10
         gpa = Double.parseDouble(tempString);
         s = new Students(fn,ln,grade,gpa);
         students.add(s);
         }
      return students;
      }
 
   //SC11 
   private static void printStudents(ArrayList<Students> students){
      int i = 1;
      for (Students n : students)
         {
         System.out.println(i+") "+n.getWholeName() + " | Grade Level: "+n.getGradeLevel()+" | GPA: "+n.getGPA());
         i++;
         }
   
      }
              
   private static int integerInputManager()
      {
      int temp;
      while(true){   
         try{  //SC4
            do{
               System.out.print("Please enter in a value between 1 and 50: ");
               temp = sc.nextInt();
               if (temp > 50 || temp <1) //SC5
                  System.out.println("Your entry is out of range.\n");
               sc.nextLine();
               }while(temp >50 || temp <1); //SC5
            return temp;
            
            }
         catch(InputMismatchException e) //SC4
            {
            sc.next();
            System.out.println("\nPlease enter a correct value.");
            }
         }
      
      }  


   }
//Given
///////////////////////////////////////////////////
class Students
   {
   String first_Name;
   String last_Name;
   int grade_Level;
   double GPA;
      
   public Students()
      {
      first_Name = "Dee";
      last_Name =  "Fault";
      grade_Level = 0;
      GPA = 0.0;
      }

   public Students(String fn, String ln, int gl, double gpa)
      {
      first_Name = fn;
      last_Name =  ln;
      grade_Level = gl;
      GPA = gpa;
      }
      
      //last, first
   public String getWholeName()
      {
      return last_Name + ", "+first_Name;
      }
      
   public String getFirstName()
      {
      return first_Name;
      }
      
   public String getLastName()
      {
      return last_Name;
      }
      
   public double getGPA()
      {
      return GPA;
      }
      
   public int getGradeLevel()
      {
      return grade_Level;
      }
      
   public void setFirstName(String fn)
      {
      first_Name = fn;
      }
    
   public void setLastName(String ln)
      {
      last_Name = ln;
      }
      
   }