Download as pdf or txt
Download as pdf or txt
You are on page 1of 2

LAB 10: FILE

Mã Môn học/Course No.: CMU-CS 303


Tên Môn học/Course Name: Fundamentals Of Computing 1
Năm học/Academic Year: 2019-2020
Học kỳ/Semester: II
Khoa hay Viện/Faculty Name: International School

Project naming convention

 Create a project named: Lab10_File_ID


 With ID stands for student’s identify
 Ex: If your student’s ID is 9600278, so your project name will be:
Lab10_File_9600278
 Pay attention to “_” (underscore)
Package naming convention: Each project has one or many packages.

 Each package has a specific name


 Each Lab has one package name. Remember to name the packages as follow: labNo_ID
 With No is a number of each lab, ID stands for student’s identify
 Ex: lab01_9600278, lab02_9600278
 Remember to use lowercase l
Class naming convention (Files): Each package has one or many classes

 Each class has a specific name


 Remember to name the classes (classname) as follow:
LabNo_ID and TestLabNo_ID

 With No is a number of each lab, ID stands for student’s identify


 Ex: Lab01_9600278, TestLab01_9600278, Lab02_9600278,
TestLab02_9600278
 Remember to capitalize each word L, T and L
1. Write a program that reads a file and writes a copy of the file to another file with line
numbers inserted
2. Write a program that reads a file that contains only one line; output all the characters, one
character per line.
3. Write a program that reads a file and counts how many lines it contains.
4. Write a program that reads a text file that contains a grade (for instance, 87) on each line.
Calculate and print the average of the grades.
5. Write a program that reads a text file and outputs every line of the file separated by a
blank line
6. Often websites display the visitor count (“You are visitor number 5246”). Write a
program that reads a file that holds the visitor count, outputs it, and updates the file,
incrementing the visitor count by 1.
7. A file contains web addresses, one on each line. Design a class that encapsulates the
concept of counting the number of college addresses (contains .edu), government
addresses (contains .gov), business addresses (contains .com), organization addresses
(contains .org), or other addresses. Test your class with a client program.
8. Design a class that attempts to determine the relative frequency of each letter by reading
a file and keeping track of the number of times each of the 26 English alphabet characters
appears. Also provide methods, such as highestFrequencyCharacter and lowest
FrequencyCharacter. Test your class with a client program.

You might also like