Image

I keep getting 2 errors with this - now keep in mind I'm still only 3 weeks into java and I don't clue into obvious stuff sometimes because I freak out about the more difficult stuff. The errors I get are: (ok, the carats won't show in the right place - the first carat should be under the semicolon and the second one should be under the n in the first new.)

A:\Ch3_PrExercise1.java:33: ')' expected
outputFile.println("The character is " + (char) + (character + 1);
^
A:\Ch3_PrExercise1.java:25: cannot resolve symbol
symbol : constructor PrintWriter (java.io.FileReader)
location: class java.io.PrintWriter
PrintWriter outputFile = new PrintWriter(new FileReader("a:\\outputFile.dat"));
^
2 errors

----jGRASP wedge2: exit code for process is 1.
----jGRASP: operation complete.

See, the whole concept of this is to print the sum of the first two numbers, the character plus one and the product of the last two numbers to an output file. My problem with that first error is that I needed to add a print line to print the character to the output file. I obviously did it wrong. I need it to concatenate the cast operator and the character variable plus 1.

The second error - I dunno. I'm mental.


import java.io.*;
import java.util.StringTokenizer;

public class Ch3_PrExercise1
{
public static void main(String[] args) throws IOException, FileNotFoundException
{
int num1;
int num2;
int num3;
int num4;
char character;
StringTokenizer tokenizer;


BufferedReader inputFile = new BufferedReader(new FileReader("a:\\inputFile.txt"));
PrintWriter outputFile = new PrintWriter(new FileReader("a:\\outputFile.dat"));

tokenizer = new StringTokenizer (inputFile.readLine());
num1 = Integer.parseInt(tokenizer.nextToken());
num2 = Integer.parseInt(tokenizer.nextToken());
outputFile.println("The sum of the first two numbers is " + (num1 + num2));

character = inputFile.readLine().charAt(0);
outputFile.println("The character is " + (char) + (character + 1);

tokenizer = new StringTokenizer (inputFile.readLine());
num3 = Integer.parseInt(tokenizer.nextToken());
num4 = Integer.parseInt(tokenizer.nextToken());
outputFile.println("The product of the last two numbers is " + (num3 * num4));

outputFile.close();
}
}


Any help would be much appreciated.