Question: The function accepts the array inv, the number of autos, and the cost per auto [for purposes of this assignment, we will assume that all
The function accepts the array inv, the number of autos, and the cost per auto [for purposes of this assignment, we will assume that all autos are sold at the same price]. The function returns the total income potential if all the autos were sold. Write a main function as follows: Create the array inv and initialize all elements to 0. Create a file transInfo. This file contains lines of data, each line representing either a sale or a receipt for a particular auto. You are to create the file on disk with the data shown below. Define and open the file (for input) in your main function. Call the function printStock (to print the current status-all autos have 0 on hand). Process the data in transInfo as follows: Each data line contains three items of information. transaction type (1 = sale; 2 = receipt) auto number (an integer 0-9) number of units (sold or received) If the transaction is a receipt, then add the number of autos to the corresponding element of the inv array; if the transaction is a sale, then subtract the number of seats from the corresponding auto inventory. For each transaction, print a log (message) describing the action that you took. Similarly, if an invalid transaction code is entered, that transaction should be rejected (and noted on the log). This step should end when there is no data remaining. Call the function printStock Call the function Sales with an appropriate message (to print the total income for all autos). For purposes of this call, assume the price of a single auto is $10000.00
Step by Step Solution
There are 3 Steps involved in it
Get step-by-step solutions from verified subject matter experts
