L10

Due by the end of Tuesday, 23 March 2021


SUBMIT   /   CHECK

Today's Activities

Programming Activity 1
Download the program SumUsersFile.java into your L10/src folder. Download the data files 3Doubles.txt and 100Doubles.txt into your L10 project folder.
Note that the data files don't go into the src folder. They go into the folder that the src folder is in (L10, or whatever you called your project).
Revise SumUsersFile so that it reads and sums doubles instead of integers. Test it using the data files provided.
Programming Activity 2
Download the program WeeklyTemps.java (into your L10/src folder). This program is the one that reads seven temperatures into an array, calculates their average, then prints out the temperatures and how far off the average they are. I want you to revise it so that it reads the temperatures from a file, where the user provides the name of the file. (The output still goes to the screen.)

Test your program using the 100Doubles.txt data file you downloaded for the previous activity. (Don't worry about the extra numbers. The program reads seven temperatures and ignores the rest.)

To think about: What happens if you use 3Doubles.txt as the input file? Why does that happen?
Programming Activity 3
Create a program called CountingBy. It asks the user for a number to count by and a number to count to. Then it asks for the name of a file. Finally, it prints the numbers into the named file. For example,
What shall I count by? 5 What shall I count to? 100 What file shall I save the numbers in? byFives.txt The file byFives.txt has been created.
And here is what would be in the file byFives.txt.

Note:

Submit this/these files:

You will be graded on the following:

  1. SumUsersFile compiles; variables revised to be double instead of int
  2. . . . checks for and reads doubles instead of ints
  3. WeeklyTemps compiles; revised to prompt for and read file name from user
  4. . . . opens file for input
  5. . . . reads correct number of temperatures from file, without prompting
  6. . . . closes input file immediately after the temperatures have been read
  7. . . . produces required output as before
  8. CountingBy compiles; prompts for and reads range of loop
  9. . . . prompts for and reads output file name
  10. . . . opens file for output
  11. . . . produces correct(ish) output to that file
  12. . . . closes that file after the output has been sent to it

SUBMIT   /   CHECK