Presentation is loading. Please wait.

Presentation is loading. Please wait.

Text Processing and More about Wrapper Classes

Similar presentations


Presentation on theme: "Text Processing and More about Wrapper Classes"— Presentation transcript:

1 Text Processing and More about Wrapper Classes

2 Contents The Test Score Problem Exercise

3 A. The Test Score Problem
Professor Harrison keeps her students’ test scores in a Microsoft Excel spreadsheet. Figure below shows a set of five test scores for five students. In addition to manipulating the scores in Excel, Dr. Harrison wants to have a Java application that accesses them. Excel, like many commercial applications, has the ability to export data to a text file.

4 When the data in a spreadsheet is exported, each row is written to a line, and the values in the cells are separated by commas. For example, when the data shown in the Figure is exported, it will be written to a text file in the following format: 87,79,91,82,94 72,79,81,74,88 94,92,81,89,96 77,56,67,81,79 79,82,85,81,90 This is called the comma separated value file format. When you save a spreadsheet in this format, Excel saves it to a file with the .csv extension. Dr. Harrison decides to export her spreadsheet to a .csv file, and wants to have a Java program that reads the file and calculates the score average for each student. Help her to do this task.

5 Solution Problem Description Preliminary Design Test Cases
Developing the Test Class Developing the Final Solution

6 1. Problem Description Calculate the score average for each student from a .csv file Input: file name Output: averages

7 2. Preliminary Design

8 3. Test Cases Input: TestScores.csv
Output: { 86.6, 78.8, 90.4, 72.0, 83.4 }

9 4. Developing the Test Class

10 5. Developing the Final Solution

11

12

13 B. Exercise The file SalesData.txt contains the dollar amount of sales that a retail store made each day for a number of weeks , , , , , , , , , , , , , , , , , , Each line in the file contains seven numbers, which are the dales numbers for one week. The numbers are separated by a comma.

14 Develop a program that opens the file and processes its contents
Develop a program that opens the file and processes its contents. The program should be able to calculate: The total sales for each week The average daily sales for each week The total sales for all of the weeks The average weekly sales The week number that had the highest amount of sales The week number that had the lowest amount of sales

15 References Starting Out with Java. From Control Structures through Objects, Chapter 10. Tony Gaddis. Pearson Education International, 2010


Download ppt "Text Processing and More about Wrapper Classes"

Similar presentations


Ads by Google