dimanche 29 mars 2015

C program, car registration code reading data



The file indata.txt contains a series of 6 lines, each containing pieces of information about a car, separated by space. In each case, the first number denotes the year of fabrication, the second text the cars number in Irish format (year, county, number), the third piece of information is the color and the fourth – cars engine volume in litres. Develop a program which will read the data from this file into an array of structures of type car_type (see below), and for each of the cars calculate and output the corresponding tax to be paid using the following algorithm: For cars no older than 5 years, the tax is Euro 150/year, if the engine is less and equal to 1.6 litres and Euro 300/year otherwise. For older cars there are three levels: less than 1.4 litres, less than 1.6 litres but greater than 1.4 litres and greater or equal to 1.6 litres. The tax is Euro 200 for the smallest engine cars, Euro 400 for the average engine size cars and Euro 600 for the highest engine size cars, respectively


indata.txt:



1991 91D2134 red 1.8
1999 99D2939 blue 1.5
2003 03C2334 red 1.2
2006 06G1123 white 1.0
1998 98D5564 blue 1.6
2005 05D1354 green 1.3



Aucun commentaire:

Enregistrer un commentaire