Thư viện tri thức trực tuyến
Kho tài liệu với 50,000+ tài liệu học thuật
© 2023 Siêu thị PDF - Kho tài liệu học thuật hàng đầu Việt Nam

Supplementary tasks file processing
Nội dung xem thử
Mô tả chi tiết
1
Chapter 9: File Processing
A. Review
A.1. What is a file pointer? How different is it from the pointers of other types? Give an example for
illustration.
A.2. What is a sequential-access file? What is a random-access file? Make a comparison between them.
Give an example of their use contexts.
A.3. Describe the required steps for reading data from a file. Give an example for illustration.
A.4. Describe the required steps for writing data into a file. Give an example for illustration.
B. Practice
B.1. Write a program to save the following table into a file that can be later opened and read with
Notepad. After that, read the saved file and find the customer who bought the products the most and
the customer who had the lowest value.
CustomerID Location ProductBought Value
121 Ho Chi Minh City 10 25.06
310 Ho Chi Minh City 15 60
400 Da Nang 8 20.83
592 Ha Noi 12 53.92
520 Nha Trang 9 24.1
B2. Write a program to update the location of all the customers whose previous location is “Ho Chi Minh
City” in B.1 and then save all the data existing and updated data back to the file.
B.3. Write a program to save the following table into a file that can not be read with Notepad. After that,
read the saved file and count the number of students in each class. The result will be then written to a
file that can be opened and read with Notepad.
StudentName Class AVG
AA Nguyễn CCO1 8.3
BB Smith CCO2 8.1
CC Kennedy CCO2 8.2
DD Lưu CCO1 8.4
EE Scott CCO2 8
B.4. Write a program to update the AVG of the student whose name is “CC Kennedy” from 8.2 to 8.5 in
B.3 and then save all the data existing and updated data back to the file.