0% found this document useful (0 votes)
15 views

Lab-6 Task

Uploaded by

mianabdullah6747
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
15 views

Lab-6 Task

Uploaded by

mianabdullah6747
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
You are on page 1/ 2

Programming Fundamentals

Lab – 6

1. Create a class called "FileReader" that has a private variable for the filename and a
public method "readFile" that reads the contents of a file and returns them as a string.

2. Create a class called "FileWriter" that has a private variable for the filename and a
public method "writeFile" that takes a string as an argument and writes it to a file.

3. Create a class called "FileCounter" that has a private variable for the filename and a
public method "countWords" that reads the contents of a file and returns the number
of words in the file.

4. Create a class called "FileCombiner" that has private variables for two filenames and a
public method "combineFiles" that reads the contents of both files and writes them to
a new file.

5. Create a class called "FileConverter" that has a private variable for the filename and a
public method "convertFile" that reads the contents of a file, converts each character
to uppercase or lowercase based on user input, and writes the modified contents to a
new file.

6. Create a class called "FileBackup" that has a private variable for the filename and a
public method "backupFile" that creates a backup of the file by appending a
timestamp to the original filename and writing the contents of the original file to the
backup file.

7. Create a class called "FileComparator" that has private member variables for two
filenames and a public method "compareFiles" that reads the contents of both files
and compares them line by line. The method should return result if both files are
same or not.

1|Page
8. Create a program that reads the contents of a file, manipulates the data, and writes
the result to a new file. The program should do the following:
a. Ask the user for the name of the input file and output file.
b. Read the contents of the input file and store them in a string.
c. Count the number of words in the input file by splitting the string into words.
d. Replace all occurrences of a user-specified substring with another user-
specified substring.
e. Write the modified string to the output file.

9. Create a class called "FileMonitor" that has a private member variable for the filename
and a public method "monitorFile" that continuously checks if the contents of the file
have been modified and performs some action if they have.

2|Page

You might also like