The following method, readin, reads in a file and process a gradebook file. The
ID: 3717900 • Letter: T
Question
The following method, readin, reads in a file and process a gradebook file. The file contains rows of the following a string indicating the name of the student, the exam score (a decimal value), and the homework score (an integer). For example, a sample file may look like the following Paul 92.3 12 Rick 0.5 2 Christine 100.4 90 Complete the code by selecting the correct choices at the blanks. Put your answer directly on the blanks public void zeadin (String filename) File file new File (filename) Scanner rin new Scanner (file) while (rin. String name - rin. double exam rin. int hw rin. //furthez processing, not part of this problem B. hasNext0 C. has0 D. File A. NullPointerException E. nextlnt0 F. nextDouble G. next J. IOException throws L. evoke H. takelntO tossExplanation / Answer
// Scanner throws FileNotFoundException which is subclass of IOException
public void readin(String filename) throws IOException {
File file = new File(filename);
Scanner rin = new Scanner(file);
// hasNext() checks if more input available
while(rin.hasNext()) {
// next() provides next string
String name = rin.next();
// nextDouble() provides next double
double exam = rin.nextDouble();
// nextInt() provides next integer
int hw = rin.nextInt();
}
}
Related Questions
Navigate
Integrity-first tutoring: explanations and feedback only — we do not complete graded work. Learn more.