Programming Eight Batch Text File 77 - 80
Programming Eight Batch Text File 77 - 80
BATCH # 8
TEXT FILE
Task 77: Write a program with the following given options. For this program you are provided with text
file “City.txt” a sample of which is shown below. A sample screen shot of the file is shown below
Option 1 will print all the cities from the city file.
Option 2 will print how many cities are there in the city file.
Option 4 will search whether a city a city exists in the file or not. Must write a
function that returns True or False.
Option 5 will ask the user a city to delete from the file and either print “City Deleted Successfully” or
print “City not found” if the city is not found in the file.
Task 78: In this task you will first make a file that follows the given format.
S8.25
C4.2
E2.2
There are 3 types of parcels and you may assume that no invalid data will be saved in the text file.
You will be provided with a text file “parcel.txt” that you can use to test your program.
Task # 79 In this program you will use a text file “Products.txt” that will be provided to you. The format
used in this file will be one field per line and every record will consist of 5 fields.
Task # 80: In this program you will use a text file Vehicle.txt with the fields of the file being saved in one
line in the given format.
<Vehcile ID><space><Make><comma><price> for example
1028 Civic,650000
The ID will be only 4 digits followed by a space. After the make there will be a comma to as a seperator.
Write a program with the following given options.
(1) Input
This option will allow the user to input data in the file. Take all the fields as input and make
it one line before writing.
(2) Print
This will print all the Vehicles in the file. Make sure to print fields seperately after removing
the seperator.
(3) Search
This option will search the Vehicle by its ID. Print the other fields if found, error otherwise.
(4) Delete
Allow the user to delete a vehicle record using the Vehicle ID.
(5) Most Expensive
Print the details of the car that is most expensive.
(6) Average Price
Print the Average Price of the Vehicle in the file.
(7) Quit