Question: Code in java import java.io.File; import java.io.FileNotFoundException; import java.util.Scanner; public class StudentDataHW { public static void main(String[] args) { File studentData = new File(StudentData2.txt); //

Code in java

import java.io.File;

import java.io.FileNotFoundException;

import java.util.Scanner;

public class StudentDataHW {

public static void main(String[] args) {

File studentData = new File("StudentData2.txt");

// #0 Declare an array to hold your 10 Student objects

try {

Scanner fileReader = new Scanner(studentData);

while (fileReader.hasNextLine()) {

// Parse out each line of input to create a new Student

// #1 Split inLine into tokens by tabs

// #2 isolate some basic student (fname, lnamw) info directly from tokens

// #3 Create a new Student2 instance with these data

// #4 decode number of classes from token, convert text to int--parseInt is an alternative to valueOf

// #5 Put the class names in an array of Strings from the right token

// Since classes are text, we can just split the string by commas

// and we're done with class names

// #6 Puts the class credits in an array of ints

// --First declare an array of ints to hold final converted data

// --use numClasses as size of array

// #6 continued We're going to need a temporary array to hold the

// text versions of the credits. Declare array and do split at same time.

// the split method will dimension the array

// #7 Follow same pattern to Convert the class credits information that are Strings into ints

// parseInt like valueOf converts a text into a real number

// #8 Put the class grades in an array like we did for credits

// First declare your array to hold the final double data

// Hint: reuse your temporary array to capture the comma-separated grades

// Convert the class grades strings into doubles

// #9 Now you have all the data needed to fully describe this instance of a Student

// Add class data to Student object using Student's public API (addClasses)

// #10 add your fully filled in Student object into your array of Students

// Hine use a counter to keep track of the current array index

}

// #11 iterate your array and print report cards

} catch (FileNotFoundException e) {

e.printStackTrace();

}

}

public static void printReportCard(Student aStudent) {

printHeader(aStudent.getName());

printDetail(aStudent.getClasses(), aStudent.getCredits(), aStudent.getGrades());

printSummary(aStudent.getClasses(), aStudent.getCredits(), aStudent.getGPA(), aStudent.getFormattedGPA());

}

public static void printDetail(String[] classNames, int[] classCredits, double[] classGrades) {

for (int i = 0; i < classNames.length; i++) {

printLineDetail(classNames[i], classCredits[i], classGrades[i]);

}

}

public static void printSummary(String[] classNames, int[] classCredits, double gpa, String fGPA) {

System.out.println("-----\t-------\t-----");

double sumCredits = 0;

for (int i = 0; i < classNames.length; i++) {

sumCredits += classCredits[i];

}

System.out.println("Total\t " + sumCredits);

System.out.println("GPA:\t " + fGPA);

if (gpa >= 3.75) {

System.out.println("!!Congratulations you made Dean's List!!");

} else if (gpa >= 3.5 && gpa < 3.75) {

System.out.println("!!Congratulations you made Honor Roll!!");

}

}

public static void printHeader(String name) {

System.out.println("Quarter Report Card for: \t" + name);

System.out.println();

System.out.println("Class\tCredits\tGrade");

System.out.println("-----\t-------\t-----");

}

public static void printLineDetail(String className, int credits,

double grade) {

System.out.println(className + "\t " + credits + "\t " + grade);

}

}

Students Data

Sally Forth 00001 II 3 ENG101,HS200,GER130 3,5,3 2.5,3.5,3.0

Linus VanPelt 00002 II 4 PSCI200,BOT100,GYM201,ENG100 4,5,5,5 3.0,3.2,3.8,4.0

Jason Fox 00003 II 4 MAT142,MAT143,MAT300,MAT403 5,5,5,5 4.0,4.0,4.0,4.0

Luann Degroot 00004 II 4 BIOL100,HIST101,CHEM201,ENG101 4,4,4,5 2.5,2.7,3.0,2.2

Lucy VanPelt 00005 II 5 MUS101,ENG101,MATH142,CS141,BOT200 3,3,4,4,3 3.0,4.0,2.8,3.3,2.5

Dagwood Bumstead 00006 II 4 BUS101,OFF300,HEC130,MTH100 3,3,3,3 1.0,2.5,3.5,3.1

Hagar Horrible 00007 II 3 HIST101,NOR400,HIST203 5,5,5 2.0,2.3,3.1

Beetle Bailey 00008 II 3 MIL101,REC100,REC200 4,3,4 1.0,4.0,3.4

Stephan Pastis 00009 II 2 ART100,PSYC205 5,3 2.0,3.5

Garry Trudeau 00010 II 3 ART200,PSCI300,PSYC305 5,5,5 4.0,4.0,3.9

Step by Step Solution

There are 3 Steps involved in it

1 Expert Approved Answer
Step: 1 Unlock blur-text-image
Question Has Been Solved by an Expert!

Get step-by-step solutions from verified subject matter experts

Step: 2 Unlock
Step: 3 Unlock

Students Have Also Explored These Related Databases Questions!