A car dealer has 10 salespersons. Each salesperson keeps track of the number of cars sold each month and reports it to the management at the end of the month. The management keeps the data in a file and assigns a number, 1 to 10, to each salesperson. The following statement declares an array, cars, of 10 components of type int to store the number of cars sold by each salesperson.


Write the code to store the number of cars sold by each salesperson in the array cars, output the total numbers of cars sold at the end of each month, and output the salesperson number selling the maximum number cars. (Assume that data is in the file cars.dat, and this file has been opened using the ifstream variable inFile.)

Respuesta :

Answer:

See explaination

Explanation:

This can be achieved using this program plan.

1. Declare local variable of type int and array int.

2. Declare the file object for input screen ifstream infile

3. Open the car.dat file using the object

4. Read the values in the fiel, store in person and car array.

5. Use if function to determine if Person have maximum car or not.

6. Compute total cars and display each sold by each person.

7. Display the total cars count.

Please check attachment for program source code screenshot.

Ver imagen kendrich