BuildingProgramF08wFILES

BuildingProgramF08wFILES - Building a Program There are...

Info iconThis preview shows pages 1–6. Sign up to view the full content.

View Full Document Right Arrow Icon
Building a Program There are several ways to construct a program but the best way is in small sections.
Background image of page 1

Info iconThis preview has intentionally blurred sections. Sign up to view the full version.

View Full DocumentRight Arrow Icon
Plan what you want to do! We are going to create a program that will read from a file and average the numbers. We are going to use Scanner to read the file. Once the file’s numbers have been averaged, we will write the average to an output file.
Background image of page 2
Create the skeleton program import java.util.*; import java.io.*; public class fileDemo { public static void main(String[] args) { } // end of main }
Background image of page 3

Info iconThis preview has intentionally blurred sections. Sign up to view the full version.

View Full DocumentRight Arrow Icon
Next decision We will be inputting into the program therefore we will need to handle all possible errors that can result from this activity. We have two choices: use the try catch syntax The disadvantage of this method is that if we create anything within the try catch it will be local use throw syntax The disadvantage of this method is that we have less control over our errors i.e., we cannot redirect the program execution if there is an error.
Background image of page 4
We will throw the exception since will we need to create the file handlers within the program and if there is a problem, the program will terminate anyway . public static void
Background image of page 5

Info iconThis preview has intentionally blurred sections. Sign up to view the full version.

View Full DocumentRight Arrow Icon
Image of page 6
This is the end of the preview. Sign up to access the rest of the document.

This note was uploaded on 09/27/2011 for the course CSC 111 taught by Professor Dr.preston during the Fall '11 term at Oral Roberts.

Page1 / 15

BuildingProgramF08wFILES - Building a Program There are...

This preview shows document pages 1 - 6. Sign up to view the full document.

View Full Document Right Arrow Icon
Ask a homework question - tutors are online