Java

TOPIC I01 – READING FROM A FILE

 

LESSON WORK

 

 

QUESTION #1

 

Create a program that will count the number of characters (including spaces) in a file.

 

QUESTION #2

 

Create a program that will count the number of occurrences of the letter “x” in a file.

 

QUESTION #3

 

Copy and paste a section of java code into a text file.  Create a program that will count the number of numeric variables (int and double) that are in your program.

 

Hint 1: All variables have to be declared in java.
Hint 2: For simplicity, assume all variables are declared on their own lines.  So no:
int x,y,z;

Hint 3: Careful not to catch typecasting such as (int) – watch for brackets.

Hint 4: You can make your program work for only a program inside the main function to avoid having to deal with return types of methods.