Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- import java.io.*;
- import java.util.*;
- public class LookSc {
- public static void main(String [] args) throws FileNotFoundException{
- Scanner sc = new Scanner (System.in);
- String lookupString = constructLookUpStringFromFile("/Users/puvitpracharktam/IdeaProjects/pondspective/src/score.csv");
- boolean toQuit = false;
- do{
- char choice = showMainMenu();
- switch choice{
- case 'L':
- commenceLookUpProcedure(lookupString);
- break;
- case 'Q':
- toQuit = true;
- break;
- default:
- System.out.println("Invalid choice. Quitting.");
- toQuit = true;
- }
- }while(!toQuit);
- }
- public static String constructLookUpStringFromFile(String f) throws FileNotFoundException{{
- Scanner sc = new Scanner(new File(f));
- sc.useDelimiter(",|\\n");
- return sc.next();
- }
- public static void commenceLookUpProcedure(String table){
- Scanner sc = new Scanner(System.in);
- System.out.print("Enter Student ID : ");
- String id = sc.next();
- String data = table.substring(table.indexOf("\n"));
- if (data.indexOf(id)>=0)
- showScore(table, id);
- else
- System.out.println("Student ID \'"+id+"\' not found in data.");
- }
- }
- public static char showMainMenu(Scanner sc)) {
- System.out.println("‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐");
- System.out.println("Main Menu");
- System.out.println("‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐");
- System.out.println("L) Look up score");
- System.out.println("Q) Quit");
- System.out.println("‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐");
- System.out.print(">> ");
- char n = sc.next().charAt(0);
- return n;
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement