/* * To change this license header, choose License Headers in Project Properties. * To change this template file, choose Tools | Templates * and open the template in the editor. */ package arrayoct20; import java.io.File; import java.io.FileNotFoundException; import java.util.Scanner; /** * * @author jcmtiernan */ public class ArrayOct20 { /** * @param args the command line arguments */ public static void main(String[] args) { File stdtData = new File("StdtGrds.txt"); Scanner input; boolean end; String lastName, firstName; //8 integers in one variable Integer[] grades; grades = new Integer[8]; // 8 doubles in one variable Double[] percent = new Double[8]; try { input = new Scanner(stdtData); end = true; } catch (FileNotFoundException fnf) { input = new Scanner(System.in); System.out.println("Please enter the following information on one line - "); System.out.println("lastName, firstName, Q1score Q1% Q2 Q2% Q3 Q3% L1 L1% L2 L2% L3 L3% T1 T1% T2 T2% "); System.out.println("Example: \"de le Santo, Carlos. 85 .01 2 .02 84 .02 81 0.15 0 0.0 86 0.3 84 .25 59 .25\" "); System.out.println("Your input is: "); } input.useDelimiter(", "); lastName = input.next(); // gets last name stopping at comma after input.findInLine(", "); // moves file pointer after lastName firstName = input.next(); // gets first name stopping at comma after input.findInLine(", "); // moves file pointer after lastName input.useDelimiter(" "); System.out.println(""+firstName+" "+lastName); /* q1 = input.nextInt(); q1p = input.nextDouble(); q2 = input.nextInt(); q2p = input.nextDouble(); q3 = input.nextInt(); q3p = input.nextDouble(); l1 = input.nextInt(); l1p = input.nextDouble(); l2 = input.nextInt(); l2p = input.nextDouble(); l3 = input.nextInt(); l3p = input.nextDouble(); t1 = input.nextInt(); t1p = input.nextDouble(); t2 = input.nextInt(); t2ps = input.nextLine(); */ /* grades[0] = 0; grades[1] = 0; grades[2] = grades[0]; grades[7] = 0; */ for(int i = 0; i < grades.length; i++ ) { grades[i] = (Integer) input.nextInt(); if (input.hasNextDouble()) { percent[i] = (Double) input.nextDouble(); } else { percent[i] = Double.parseDouble(input.nextLine()); } } System.out.printf(" grade[8] %4d \n",grades[8]) for(int i = 0; i <= grades.length; i++ ) { System.out.printf("%4d %6.2f \n",grades[i],percent[i]); } } }