Academic Integrity: tutoring, explanations, and feedback — we don’t complete graded work or submit on a student’s behalf.

Assume that BROOKLYN AUTOS maintains data on up to 10 cars on a daily basis (the

ID: 3713215 • Letter: A

Question

Assume that BROOKLYN AUTOS maintains data on up to 10 cars on a daily basis (these autos are numbered 0-9). This information is maintained in an array inv which stores the current information for cach auto. For example if invI3] 20, this means that there are 20 autos of type 3 currently in stock. Initially, all autos have 0 on hand I. Write a method printStock. This function accepts the array inv and the number of autos and prints a chart showing the auto number along with the current inventory Write a method Sales. This function calculates the total value of all autos on hand 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 retums the total income potential if all the autos were sold (Hint compute the total number of autos and multiply by the price.) 2. 3. Write a main method 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 purchase or a return 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 method Call the method 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 return) auto number (an integer 0-9) number of units (sold or receip) 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. Note: If an attempt is made to purchase more autos than are currently available, that transaction should be rejected (and noted on the log). Similarly, if an invalid transaction code is entered, that transaction should be rejected (and noted on the log). This step should end when a data line of all "-1" is encountered Call the method 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

Explanation / Answer

Solution to given problem is provided below along with sample input and output. Comments are also added within code for readability.

File: BrooklynAutos.java

Sample Input (File: transInfo):

Sample Execution Output:

AUTO STOCK:
0 autos of type 1
0 autos of type 2
0 autos of type 3
0 autos of type 4
0 autos of type 5
0 autos of type 6
0 autos of type 7
0 autos of type 8
0 autos of type 9
0 autos of type 10
TRANSACTION::2 0 1:: Receipt of 1 autos of type 1
TRANSACTION::2 1 2:: Receipt of 2 autos of type 2
TRANSACTION::2 2 3:: Receipt of 3 autos of type 3
TRANSACTION::2 3 4:: Receipt of 4 autos of type 4
TRANSACTION::2 4 5:: Receipt of 5 autos of type 5
TRANSACTION::2 5 6:: Receipt of 6 autos of type 6
TRANSACTION::2 6 7:: Receipt of 7 autos of type 7
TRANSACTION::2 7 8:: Receipt of 8 autos of type 8
TRANSACTION::2 8 9:: Receipt of 9 autos of type 9
TRANSACTION::2 9 10:: Receipt of 10 autos of type 10
TRANSACTION::2 10 0:: Invalid Auto Number 10
TRANSACTION::1 0 1:: Sale of 1 autos of type 1
TRANSACTION::1 1 1:: Sale of 1 autos of type 2
TRANSACTION::1 2 1:: Sale of 1 autos of type 3
TRANSACTION::1 3 1:: Sale of 1 autos of type 4
TRANSACTION::1 4 1:: Sale of 1 autos of type 5
TRANSACTION::1 5 1:: Sale of 1 autos of type 6
TRANSACTION::1 6 1:: Sale of 1 autos of type 7
TRANSACTION::1 7 1:: Sale of 1 autos of type 8
TRANSACTION::1 8 1:: Sale of 1 autos of type 9
TRANSACTION::1 9 1:: Sale of 1 autos of type 10
TRANSACTION::1 10 1:: Invalid Auto Number 10
TRANSACTION::1 9 10:: Rejected Sale of 10 autos of type 10 as it exceeds available inventory 9
AUTO STOCK:
0 autos of type 1
1 autos of type 2
2 autos of type 3
3 autos of type 4
4 autos of type 5
5 autos of type 6
6 autos of type 7
7 autos of type 8
8 autos of type 9
9 autos of type 10
Total value for all autos = $450000.0

Hire Me For All Your Tutoring Needs
Integrity-first tutoring: clear explanations, guidance, and feedback.
Drop an Email at
drjack9650@gmail.com
Chat Now And Get Quote