Question: Looking for help in java. I need to add a delete from CSV and a search CSV function on student records. Not looking for answers
Looking for help in java.
I need to add a delete from CSV and a search CSV function on student records.
Not looking for answers to just be given, I need comments as to what its doing also.
this is my menu.
public static void main(String[] args){ //declare strings String studentName = ""; String studentYear = ""; //double for gpa double studentGPA = -1; //int for invalid input/unanswered question int invalidInput = 0; int missingInfo; //initiate scanner Scanner scnr = new Scanner(System.in); //create string to hold user input String userInput = "-1"; //open file File myFile = new File(filePath(scnr)); do{ mainMenu(); System.out.println("Enter menu selection"); userInput = scnr.next(); if(userInput.equals("1")) { System.out.println("Enter students name: "); studentName = scnr.next(); }else if(userInput.equals("2")){ System.out.println("Enter students year: "); studentYear = scnr.next().toLowerCase(); //check for valid input invalidInput = validEntry(studentYear, 0); if(invalidInput > 0){ studentYear = ""; } }else if(userInput.equals("3")){ System.out.println("Enter student GPA: "); try{ studentGPA = scnr.nextDouble(); //check if input is valid invalidInput = validEntry("senior", studentGPA); if (invalidInput > 0){ studentGPA = -1; } }catch (Exception ex){ System.out.println("Only a double variable accepted, try again"); studentGPA = -1; scnr.nextLine(); } }else if(userInput.equals("4")){ //print student data System.out.println("Student name: " + studentName + " "); System.out.println("Student year: " + studentYear + " "); System.out.println("Student GPA: " + studentGPA); }else if(userInput.equals("5")){ missingInfo = missingData(studentName, studentYear, studentGPA); if(missingInfo == 0 && invalidInput == 0){ writeToFile(studentName, studentYear, studentGPA, myFile); }else { System.out.println("Entries invalid"); } }else if(userInput.equals("6")){ fileReader(myFile); }else if(userInput.equals("7")){ }else if(userInput.equals("8")){ } else{ System.out.println("Invalid input, please select a number 1-8"); scnr.nextLine(); } }while(!userInput.equals("9")); }
Step by Step Solution
There are 3 Steps involved in it
Get step-by-step solutions from verified subject matter experts
