As of right now I'm a beginner with programming and Java and I've only had a few months of practice so far. This is a project I've been working on as practice. It's essentially a basic course manager that a college professor or someone similar could use.I'd like to get some feedback on any aspect of this program. Things I did wrong, bad habits, or things I could improve, shorten, simplify etc.package courseManager;import java.util.ArrayList;import java.util.InputMismatchException;import java.util.Scanner;public class CourseManagment {    public static ArrayList<Course> courses = new ArrayList<>();    public static int getIndex(String viewID) {        for(int n = 0 ; n < courses.size() ; n++) {            if(courses.get(n).getID().equals(viewID)) {                return n;            }        }        return -1;    }    public static int checkYesNo() {        Scanner input = new Scanner(System.in);        String action = ;        while(!action.equalsIgnoreCase(n) || (!action.equalsIgnoreCase(y))) {            action = input.nextLine();            if(action.equalsIgnoreCase(y)) {                return 1;            }            if(action.equalsIgnoreCase(n)) {                return 2;            }            if(!action.equalsIgnoreCase(y) || !action.equalsIgnoreCase(n)) {                System.out.println(Not a valid action. Enter Y or N. );            }        }        return 0;    }    public static void main(String[]args) {        // Variables        int refIndex = 0;        String name = ;        String id = ;        int numStudents = 0;        ArrayList<String> roster = new ArrayList<>();        String meetDay = ;        String meetTime = ;        String action = ;        String task = ;        String viewID = ;        String modify = ;        String removeStudent = ;        String addStudent = ;        Scanner input = new Scanner(System.in);        // Main code        while(!task.equals(end)) {            System.out.println(What would you like to do? Add or remove a course, modify an existing course, or view a course?                     + Type 'add', 'remove', 'modify', or 'view'. Type 'end' to stop the program. );            task = input.nextLine();            if(task.equals(end)) {                break;            }            // Create course block            if(task.equals(add)) {                while(!action.equals(done)) {                    System.out.println(Enter the name of the course. Type 'done' when you're finished adding. );                    courses.add(new Course(name, id, numStudents, roster, meetDay, meetTime));                    System.out.println(Course added. Add another course? Y/N );                    if(checkYesNo() == 2) {                        break;                    }                }            }            // Remove course block            if(task.equals(remove)) {                while(!action.equals(done)) {                    System.out.println(Enter the name of the course you wish to remove. Type 'done' when you're finished removing. );                    viewID = input.nextLine();                    if(getIndex(viewID) == -1) {                        System.out.println(No course with this ID exists. Enter a valid course ID. \n);                        break;                    }                    if(getIndex(viewID) != -1) {                        courses.remove(getIndex(viewID));                        System.out.println(Course removed. Remove another course? Y/N );                        if(checkYesNo() == 2) {                            break;                        }                    }                }            }            // Modify block            if(task.equals(modify)) {                System.out.println(Enter the ID of the course you wish to modify. );                viewID = input.nextLine();                if(getIndex(viewID) == -1) {                    System.out.println(Not a valid course ID. );                }                if(getIndex(viewID) != -1) {                    refIndex = getIndex(viewID);                    while(!modify.equals(done)) {                        System.out.println(What parameter of the course do you wish to modify? Type 'name', 'ID', '#students', 'meet day', or 'meet time'.                                 + If you wish to add or remove students type 'add student' or 'remove student'. );                        modify = input.nextLine();                        if(modify.equals(back)) {                            break;                        }                        if(modify.equals(name)) {                            courses.get(refIndex).ChangeName();                        }                        if(modify.equals(ID)) {                            courses.get(refIndex).ChangeID();                        }                        if(modify.equals(#students)) {                            courses.get(refIndex).ChangeNumStudents();                        }                        if(modify.equals(meet day)) {                            courses.get(refIndex).ChangeMeetDay();                        }                        if(modify.equals(meet time)) {                            courses.get(refIndex).ChangeMeetTime();                                                 }                        if(modify.equals(add student)) {                            while(!addStudent.equals(done)) {                                System.out.println(Enter the name of the student you wish to add. Type 'done' when you're finished adding. );                                addStudent = input.nextLine();                                if(addStudent.equals(done)) {                                    break;                                }                                courses.get(refIndex).AddStudent(addStudent);                            }                        }                        if(modify.equals(remove student)) {                            while(!removeStudent.equals(done)) {                                System.out.println(Enter the name of the student you wish to remove. Type 'done' when you're finished removing. );                                removeStudent = input.nextLine();                                if(removeStudent.equals(done)) {                                    break;                                }                                courses.get(refIndex).RemoveStudent(removeStudent);                            }                        }                    }                }            }            // View block            if(task.equals(view)) {                System.out.println(Enter the ID of the course you want to view. );                viewID = input.nextLine();                if(getIndex(viewID) == -1) {                    System.out.println(No course with this ID exists. Enter a different ID. \n);                }                if(getIndex(viewID) != -1) {                    System.out.println(courses.get(getIndex(viewID)));                }            }        }        input.close();    }}class Course {    // toString override for the Course class    @Override    public String toString() {        return \n Course name:  + name + \n Course ID:  + id + \n Current # of students:  + roster.size() + / + numStudents + \n Student roster:  + roster            + \n Meeting day:  + meetDay + \n Meeting time:  + meetTime + \n;    }    Scanner input = new Scanner(System.in);    // Course properties    String name;    String id;    int numStudents;    ArrayList<String> roster;    String meetDay;    String meetTime;    String addStudent;    String removeStudent;    // Course constructor    Course(String name, String id, int numStudents, ArrayList<String> roster, String meetDay, String meetTime) {        // User entered course properties            this.name = input.nextLine();        System.out.println(Enter the course ID. );            this.id = input.nextLine();        System.out.println(Enter the max number of students. );        while(!input.hasNextInt()) {            try {                this.numStudents = input.nextInt();                input.nextLine();            } catch (InputMismatchException e) {                System.out.println(This value needs to be a number...\nEnter the max number of students. );                input.nextLine();            }        }        input.nextLine();            this.roster = new ArrayList<String>();        System.out.println(Enter the meeting day of the course. );            this.meetDay = input.nextLine();        System.out.println(Enter the meeting time of the course. );            this.meetTime = input.nextLine();    }    // Modify Course methods    String getID() {        return this.id;    }    public void ChangeName() {        System.out.println(Enter the new name of the course. );        this.name = input.nextLine();    }    public void ChangeID() {        System.out.println(Enter the new ID of the course. );        this.id = input.nextLine();    }    public void ChangeNumStudents() {        System.out.println(Enter the new max number of students of the course. );        while(!input.hasNextInt()) {            try {                this.numStudents = input.nextInt();                input.nextLine();            } catch (InputMismatchException e) {                System.out.println(This value needs to be a number...\nEnter the max number of students. );                input.nextLine();            }        }        input.nextLine();    }    public void ChangeMeetDay() {        System.out.println(Enter the new meeting day of the course. );        this.meetDay = input.nextLine();    }    public void ChangeMeetTime() {        System.out.println(Enter the new meeting time of the course. );        this.meetTime = input.nextLine();    }    public void AddStudent(String addStudent) {        this.roster.add(addStudent);    }    public void RemoveStudent(String removeStudent) {        this.roster.remove(removeStudent);    }}
Course manager Java program
java;beginner
I decided to restructure your code out of boredom and for a little java practice myself. Also I thought it would be nifty for you to see your project through someone else's eyes. Whether the code below is the best way to achieve the task at hand or not, there are still quite a few things you will be able to take from my code. I'll walk through each class and show you what I changed.Things to take note of (CourseManagement Class):First off, you generally want to separate your code into functions based on said code's functionality, instead of reading through one giant mother block of code. Not only are functions used for code reuse-ability, they're also useful for code readability, which is just as important. Speaking of readability, blank lines at certain positions can be quite useful. The reason I bring this up is because I notice you had none. If blank lines are not your thing, you should at least place them in between functions and between logical sections inside a method.Generally when checking for string cases, its better to use a switch case method. If statements are normally reserved for Boolean logic. If you must use if statements though, at least use if, else if, else statements when able. It is generally bad practice to separate group able questions into their own if statements like you have done. Your program will continue to ask questions that it already knows the answer to.For more code conventions take a look at: Java Code Conventionsimport java.text.ParseException;import java.util.ArrayList;import java.util.List;import java.util.Scanner;/** * Created on 7/29/2016. * */public class CourseManagement {    private static List<Course> courses = new ArrayList<>(); // Stores course objects.    public static void main(String[] args){        loop:while(true){            String input = prompt(Add, Remove, Display, Modify, Exit >>> ).toLowerCase();            // Checks acquired input to each case expected.            switch(input){                case add : addCourse(); break;                case remove : removeCourse(); break;                case display : displayCourses(); break;                case modify : modifyCourse(); break;                case exit : break loop;                case  : continue loop;                default : System.out.printf('%s' unrecognized command.%n, input);            }        }    }    private static void addCourse(){        try{            String name = prompt(Course Name: );            String id = prompt(Course ID: );            String date = prompt(Course Meet Time(YYYY-MM-DD HH:MM): );            courses.add(new Course(name, Integer.valueOf(id), date));        } catch(ParseException ex){            System.out.println(Date Could Not Be Parsed.);        }    }    private static void removeCourse(){        try{            courses.remove(courses.get(getCourseIndex(Integer.valueOf(prompt(Course ID: )))));        } catch(ArrayIndexOutOfBoundsException ex){            System.out.println(Course Does Not Exist.);        }    }    private static void displayCourses(){        if(courses.size() <= 0){            System.out.println(No Current Courses.);        } else {            courses.forEach(i -> System.out.printf(Course Name: %s Course ID: %s Course Date: %s%n, i.getName(), i.getID(), i.getDate()));        }    }    private static void modifyCourse(){        String firstName, lastName, fullName;        int id;        Course course = courses.get(getCourseIndex(Integer.valueOf(prompt(Course ID: )))); // Selected course to modify.        loop:while(true){            String input = prompt(Add Student, Remove Student, Display Roster, Display Time, Change ID, Change Name, Change Time, Exit >>> ).toLowerCase();            switch(input){                case add student :                    firstName = prompt(Student First Name: );                    lastName = prompt(Student Last Name: );                    id = Integer.valueOf(prompt(Student ID: ));                    course.addStudent(new Student(firstName, lastName, id)); break;                case remove student :                    fullName = prompt(Student Full Name: );                    id = Integer.valueOf(prompt(Student ID: ));                    course.removeStudent(fullName, id); break;                case display roster : course.displayRoster(); break;                case display time : course.displayTime(); break;                case change id : course.changeID(Integer.valueOf(prompt(New ID: ))); break;                case change name : course.changeName(prompt(New Name: )); break;                case change time :                    try{                        course.changeMeetTime(prompt(New Date(YYYY-MM-DD HH:MM): ));                    } catch(ParseException ex){                        System.out.println(Date Could Not Be Parsed.);                    }                    break;                case exit : break loop;                case  : continue loop;                default : System.out.printf('%s' unrecognized command., input);            }        }    }    // Finds the index of wanted course within the course collection.    private static int getCourseIndex(int id){        for(int i = 0; i < courses.size(); i++){            if(courses.get(i).getID() == id){                return i;            }        }        return -1;    }    // Used to print a message and acquire user input.    // Used in the interest of code reuse-ability    private static String prompt(String message){        System.out.print(message);        return new Scanner(System.in).nextLine();    }}Things to take note of (Course Class):Your constructor needs work. You have the constructor set up to take arguments when a new instance of the class is being created, but you never use them. Notice in my example the parameters are actually used.import java.text.ParseException;import java.text.SimpleDateFormat;import java.util.ArrayList;import java.util.Date;import java.util.List;/** * Created on 7/29/2016. * */public class Course {    private String name;    private Date date;    private int id;    private List<Student> roster = new ArrayList<>();    private final SimpleDateFormat dateFormat = new SimpleDateFormat(yyyy-MM-dd hh:mm);    private final SimpleDateFormat timeFormat = new SimpleDateFormat(hh:mm);    public Course(String name, int id, String date) throws ParseException {        this.name = name;        this.id = id;        this.date = dateFormat.parse(date);    }    public String getName(){        return name;    }    public int getID() {        return id;    }    public String getDate(){        return date.toString();    }    public void displayRoster(){        roster.forEach(i -> System.out.printf(%s %s ID: %s%n, i.getFirstName(), i.getLastName(), i.getID()));        System.out.printf(Roster Size: %d%n, roster.size());    }    public void addStudent(Student student) {        roster.add(student);    }    public void removeStudent(String fullName, int id){        roster.removeIf(i -> i.getFullName().equals(fullName) && i.getID() == id);    }    public void displayTime(){        System.out.println(timeFormat.format(date));    }    public void changeName(String newName) {        name = newName;    }    public void changeID(int newID) {        id = newID;    }    public void changeMeetTime(String newDate) throws ParseException {        this.date = dateFormat.parse(newDate);    }}An added class:I decided to make a student class, that way the students information could be easily added onto and manipulated. If you're up for the challenge, here are some things that can be added onto the student class.Student test grades and average.Student homework grades and average.Student overall average. (Test grades are 70%, Homework grades are 30%)And a few things that can be added to the course class, knowing the above information.Course test average.Course homework average.Course average.  Best of luck and happy coding. /** * Created on 7/29/2016. * */public class Student{    private String firstName, lastName, fullName;    private int ID;    public Student(String firstName, String lastName, int ID){        this.firstName = firstName;        this.lastName = lastName;        this.fullName = firstName +   + lastName;        this.ID = ID;    }    public String getFirstName() {        return firstName;    }    public String getLastName() {        return lastName;    }    public String getFullName() {        return fullName;    }    public int getID() {        return ID;    }}