anonymous
2009-02-16 22:23:52 UTC
1. Consider the following incomplete Java program:
public class Ch3_PrExercise1
{
public static void main(String[] args)
{
...
}
}
ƒa. Write Java statements that import the classes Scanner, FileReader, Print-
Writer, and FileWriter from the packages java.util and java.io.
b. Write statements that declare inFile to be a reference variable of the type
Scanner and outFile to be a reference variable of the type PrintWriter.
c. The program will read the data from the file inData.txt and write the output to
the file outData.dat.Write statements to open both these files, associating
inFile with inData.txt, and associating outFile with outData.dat.
d. Suppose that the file inData.txt contains the following data:
56 38
A
7 8
Write statements so that after the program executes, the contents of the file
outData.dat are as shown below. If necessary, declare additional variables.
Your statements should be general enough so that if the content of the input file
changes and the program is run again (without editing and recompiling), it outputs
the appropriate results.
The sum of 56 and 38 = 94.
The character that comes after A in the Unicode set is B.
The product of 7 and 8 = 56.
e. Write the statement that closes the output file.
f. Write a Java program that tests the Java statements you wrote in parts a through e.