SophiaPretty

(5)

$14/per page/Negotiable

About SophiaPretty

Levels Tought:
Elementary,Middle School,High School,College,University,PHD

Expertise:
Accounting,Algebra See all
Accounting,Algebra,Applied Sciences,Architecture and Design,Art & Design,Biology,Business & Finance,Calculus,Chemistry,Communications,Computer Science,Economics,Engineering,English,Environmental science,Essay writing Hide all
Teaching Since: Jul 2017
Last Sign in: 304 Weeks Ago, 1 Day Ago
Questions Answered: 15833
Tutorials Posted: 15827

Education

  • MBA,PHD, Juris Doctor
    Strayer,Devery,Harvard University
    Mar-1995 - Mar-2002

Experience

  • Manager Planning
    WalMart
    Mar-2001 - Feb-2009

Category > Computer Science Posted 12 Dec 2017 My Price 10.00

import java.util.Scanner; import java.util.ArrayList;

I need to be able to sort the list by First Name, Last Name, or Gender.

I'm having a hard time figuring out how.


  • import java.util.Scanner;
    import java.util.ArrayList;

    public class Driver {

        public static void main(String[] args) {
            new Driver();
           
        }
       
        public Driver() {
            ArrayList<Student> studentList = new ArrayList<Student>();
            Scanner input = new Scanner(System.in);
           
            System.out.println("Select an option below");
            System.out.println("");
             
            while(true) {
                System.out.println("1: Add Student");
                System.out.println("2: Display Student");
                System.out.println("3: Remove Student");
                System.out.println("4: Sort Students");
                System.out.println("0: Exit");
                 
                   int userChoice = input.nextInt();        
                   switch(userChoice) {         
                   case 1:
                       addStudent(studentList);
                       break;
                   case 2:
                       displayStudent(studentList);
                       break;
                   case 3:
                       removeStudent(studentList);
                       break;
                   case 4:
                       System.out.println("Enter Sort Type: ");
                       System.out.println("1: Sort by First Name");
                       System.out.println("2: Sort by Last Name");
                       System.out.println("3: Sort by Gender");
                      
                       int sortType = input.nextInt();
                       switch(sortType) {
                       case 1:
                           sortStudent(); //by First Name
                           break;
                       case 2:
                           sortStudent(); //by Last Name
                           break;
                       case 3:
                           sortStudent(); //by Gender
                           break;
                       }

                       break;
                   case 0:
                       System.out.println("Thank you! See you again!");
                       System.exit(0);
                   }
            }
        }
       
        private void sortStudent() {

            }



        private void addStudent(ArrayList<Student>studentList) {
            Student newStudents = new Student();
            Scanner input = new Scanner(System.in);
            String FirstName, LastName, Gender, Major, NetID;
            double GPA;
            int Age, UIN;
            Student students;
           
            if(studentList.size() >= 10) {
                System.out.println("Your list is full!");
            } else {

            System.out.print("Enter First Name: ");
            FirstName = input.nextLine();
            System.out.print("Enter Last Name: ");
            LastName = input.nextLine();
            System.out.print("Enter Student Gender (M for Male and F for Female): ");
            Gender = input.nextLine();
           
            while(!Gender.equalsIgnoreCase("M") && !Gender.equalsIgnoreCase("F")) {
                System.out.print("Please select: M or F, Try Again: ");
                Gender = input.nextLine();
            }

           
            newStudents.setFirstName(FirstName);
            newStudents.setLastName(LastName);
            newStudents.setGender(Gender);

           
            studentList.add(studentList.size(), newStudents);
           
            System.out.println("Added!");
            System.out.println("");

        }
        }
       
        private void removeStudent(ArrayList<Student>studentList) {
            Scanner input = new Scanner(System.in);
            String RemoveFirstName;
            boolean found = false;
           
            if(studentList.isEmpty()){
                System.out.println("List is empty!");
                System.out.println("");
            } else {
                System.out.print("Enter NetID of Student to remove: ");
                RemoveFirstName = input.nextLine();
                for(int i = 0; i < studentList.size(); i++) {
                    if(studentList.get(i).getFirstName().equalsIgnoreCase(RemoveFirstName)) {
                        studentList.remove(i);
                        System.out.println("Removed!");
                        System.out.println("");
                        found = true;
                        break;                   
                    }
                }
                if(found) {
                   
                } else {
                    System.out.println("No Match!");
                    System.out.println("");
                }
            }

           
        }
                   

        private void displayStudent(ArrayList<Student>studentList) {
            if(studentList.isEmpty()) {
                System.out.println("List is empty!");
                System.out.println("");
            } else {
            System.out.println("\n Student List : ");
            for(int i = 0; i < studentList.size(); i++) {
                System.out.println(studentList.get(i).toString());
                System.out.println("");
            }
            }

           

           
        }
        }

Answers

(5)
Status NEW Posted 12 Dec 2017 11:12 AM My Price 10.00

-----------  ----------- H-----------ell-----------o S-----------ir/-----------Mad-----------am ----------- Th-----------ank----------- yo-----------u f-----------or -----------you-----------r i-----------nte-----------res-----------t a-----------nd -----------buy-----------ing----------- my----------- po-----------ste-----------d s-----------olu-----------tio-----------n. -----------Ple-----------ase----------- pi-----------ng -----------me -----------on -----------cha-----------t I----------- am----------- on-----------lin-----------e o-----------r i-----------nbo-----------x m-----------e a----------- me-----------ssa-----------ge -----------I w-----------ill----------- be----------- qu-----------ick-----------ly

Not Rated(0)