Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

Consider a comma-separated file that contains student names and scores such as the following: Jane Lee, 180, 98, 97, 198 Aaron X. Schmidt, 37,

  

Consider a comma-separated file that contains student names and scores such as the following: Jane Lee, 180, 98, 97, 198 Aaron X. Schmidt, 37, 42, 49, 54 Frank von Tardy, 2, 3, 10, 7 We can read the file one line at a time and use the indexOf method to get the positions of the commas. The call line.indexOf(",", pos) gives the position of the next comma at or beyond the position pos, or -1 if there is no match. Rearrange the lines below to compute the total score for a student. Assume that each student has at least one score Unused String name = line.substring(0, end); int start = end + 1; score = score.trim(); end = if (end == -1) } { } line.indexOf(",", start); score = line.substring (start, end); else total = total + Integer.parseInt(score); while (end != -1) { String score; Scores.java import java.util.Scanner; public class Scores { public static void calculateScore (String line) { } int total = } 0; System.out.println(name + 11 } Load default template... 11 public static void main (String [] args) { + total); Scanner in = new Scanner (System.in); while (in.hasNextLine()) { calculateScore (in.nextLine()); Unused end if (end } { } else line.. = line.indexOf(",", start); -1) } score = = line.substring(start, end); total = == total + Integer.parseInt(score); while (end != -1) { String score; int end line.indexOf(",", 0); { score = line.substring (start); Scores.java ***** import java.util.Scanner; public class Scores { public static void calculateScore (String line) { } int total = 0; System.out.println(name + } Load default template... public static void main (String [] args) { + total); } Scanner in = new Scanner(System.in); while (in.hasNextLine()) { calculateScore (in.nextLine()); Consider a comma-separated file that contains student names and scores such as the following: Jane Lee, 180, 98, 97, 198 Aaron X. Schmidt, 37, 42, 49, 54 Frank von Tardy, 2, 3, 10, 7 We can read the file one line at a time and use the indexOf method to get the positions of the commas. The call line.indexOf(",", pos) gives the position of the next comma at or beyond the position pos, or -1 if there is no match. Rearrange the lines below to compute the total score for a student. Assume that each student has at least one score Unused String name = line.substring(0, end); int start = end + 1; score = score.trim(); end = if (end == -1) } { } line.indexOf(",", start); score = line.substring (start, end); else total = total + Integer.parseInt(score); while (end != -1) { String score; Scores.java import java.util.Scanner; public class Scores { public static void calculateScore (String line) { } int total = } 0; System.out.println(name + 11 } Load default template... 11 public static void main (String [] args) { + total); Scanner in = new Scanner (System.in); while (in.hasNextLine()) { calculateScore (in.nextLine()); Unused end if (end } { } else line.. = line.indexOf(",", start); -1) } score = = line.substring(start, end); total = == total + Integer.parseInt(score); while (end != -1) { String score; int end line.indexOf(",", 0); { score = line.substring (start); Scores.java ***** import java.util.Scanner; public class Scores { public static void calculateScore (String line) { } int total = 0; System.out.println(name + } Load default template... public static void main (String [] args) { + total); } Scanner in = new Scanner(System.in); while (in.hasNextLine()) { calculateScore (in.nextLine());

Step by Step Solution

3.38 Rating (154 Votes )

There are 3 Steps involved in it

Step: 1

The above image is the correct arrangement of given lines of code input jane ... blur-text-image

Get Instant Access to Expert-Tailored Solutions

See step-by-step solutions with expert insights and AI powered tools for academic success

Step: 2

blur-text-image

Step: 3

blur-text-image

Ace Your Homework with AI

Get the answers you need in no time with our AI-driven, step-by-step assistance

Get Started

Recommended Textbook for

Income Tax Fundamentals 2013

Authors: Gerald E. Whittenburg, Martha Altus Buller, Steven L Gill

31st Edition

1111972516, 978-1285586618, 1285586611, 978-1285613109, 978-1111972516

More Books

Students also viewed these Programming questions

Question

How are writable CDs implemented?

Answered: 1 week ago

Question

What are the elements of language? LO.1

Answered: 1 week ago

Question

L A -r- P[N]

Answered: 1 week ago