Question: Lab 5 Txt 3 CS 3.5 CS 3 IT 3.9 CS 3.3 CS 3.5 CS 3.4 CS 3.9 IT 3.1 CS 3.3 CS 1.3 CS

 Lab 5 Txt 3 CS 3.5 CS 3 IT 3.9 CS3.3 CS 3.5 CS 3.4 CS 3.9 IT 3.1 CS 3.3 CS

Lab 5 Txt

3 CS 3.5 CS 3 IT 3.9 CS 3.3 CS 3.5 CS 3.4 CS 3.9 IT 3.1 CS 3.3 CS 1.3 CS 3.3 IT 3 IT 3.3 CS 3 IT 3.7 CS 3.7 CS 1.6 CS 3.1 CS 3.4 CS 3.3 IT 3.3 IT 1.3 CS 3.3 CS 3.1 CS 1.6 CS 3.9 IT 3.9 CS 3.3 CS 1.7 IT 3.8 CS 3.8 IT 3.8 CS 3.9 CS 3.8 IT 3.7 CS 3.9 IT 3.8 IT 3.7 CS 3.8 CS 3.3 CS 3.4 IT 1.1 CS 1.8 IT 3.7 CS 3.1 CS 3.3 CS 3.4 IT 3.9 IT 3.9 CS 3.5 IT 3.3 IT 3.5 IT

Objectives Reading data from a file Using multiple ArrayList to store String and numbers from the file While Loops Instructions First download the file called lab5.txt and add it to your project as shown in the videos Write a program that does the following: 1) Open the file for input. a) Create 2 ArrayLists. i) The first ArrayList will hold the student degree which is a String ii) The second ArrayList will hold the student grade which is a double b) Use a while loop to input 2 pieces of data at a time from the file (Open monday.txt to see how it's formatted). Each line represents a single student. i) The student grade which is a double. (1) Add it to the student grade ArrayList ii) The student degree which is "IT" or "CS" (1) Add it to the student degree ArrayList 2) After you fall out of the while loop a) close the file b) Output a string to indicate what each column holds c) Use another while loop to print out the information for each student on a single line from the two ArrayLists. (Your while loops will be based on the size of the Arraylist as shown in the Chapter 5 video and the Chapter 5 - More ArrayList Examples video.) d) Example Output Degree Grade 3.0 3.5 3.0 3.9 3.3 3.5 3.4 CS CS IT CS CS CS CS CSI 2300 Lab 5 3) After you fall out of the for loop use a while loop to loop through the all the degrees stored in the student degree ArrayList (Your while loops will be based on the size of the Arraylist as shown in the Chapter 5 video and the Chapter 5 - More ArrayList Examples video.) a) Inside the while loop write an if block using the degree as an expression to compare against i) if degree is "CS" add the grade from the student grade ArrayList to a CS sum, and increment a counter for the number of CS students ii) if degree is "IT" add the grade from the student grade ArrayList to a IT sum, and increment a counter for the number of IT students b) When the loop finishes print out average CS grade and average IT grade c) Example output Average grade is for cs is 3.2 Average grade is for IT is 3.3

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!