A retail store has five bins, numbered 1 to 5, each containing a different commo
ID: 3553092 • Letter: A
Question
A retail store has five bins, numbered 1 to 5, each containing a different commodity. At the beginning of a particular day, each bin contains 50 items. The table below shows the cost per item for each of the bins, and the quantity sold during that day.
Write a program to
(a) -read sales data from a file (cis14l6.txt)
(b) -Place the cost per item and the quantity sold for each bin into an array of structures;
(c) -Display a table giving the inventory at the end of the day and the amount of revenue obtained from each bin;
(d) -Compute the total revenue for the day;
(e) -List the number of each bin that contains fewer than 25 items at the end of the day.
(f) -Sort the list from least sold to most sold, and output that result.
Format of cis14l6.txt:
1 13.00 20
2 2.25 35
3 7.45 19
4 17.49 42
5 34.95 17
Column 1 is the bin number, column two is the price, and column 3 is number sold for the day.
I mainly need help with Part (A) and Part (F)... Thank you
Explanation / Answer
Public Class Form1
Dim bin() As Integer = {1, 2, 3, 4, 5}
Dim price() As Double = {3, 12.25, 37.45, 7.49, 24.95}
Dim begInv() As Integer = {45, 45, 45, 45, 45}
Dim qtySold() As Integer = {10, 30, 9, 42, 17}
Dim n As Integer = bin.Count
Dim endInv(n - 1) As Integer
Dim rev(n - 1) As Double
Dim invChk(n - 1) As String
Private Sub Form1_Load(ByVal sender As System.Object, ByVal e As System.EventArgs)
ListBox1.Items.Clear()
ListBox2.Items.Clear()
ListBox3.Items.Clear()
For i As Integer = 0 To (n - 1) Step 1
ListBox1.Items.Add(bin(i))
ListBox2.Items.Add(price(i)) 'showing the array for easy validation
ListBox3.Items.Add(qtySold(i)) 'showing the array for easy validation
Next
End Sub
Private Sub Button1_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button1.Click
ListBox4.Items.Clear()
ListBox5.Items.Clear()
ListBox6.Items.Clear()
Rug.Text = ""
For i As Integer = 0 To (n - 1) Step 1
rev(i) = price(i) * qtySold(i)
ListBox4.Items.Add(rev(i))
endInv(i) = begInv(i) - qtySold(i)
ListBox5.Items.Add(endInv(i))
If endInv(i) < 20 Then
invChk(i) = "Low Inv!"
Else
invChk(i) = ""
End If
ListBox6.Items.Add(invChk(i))
Next
Rug.Text = FormatCurrency(rev.Sum, 2)
End Sub
End Class
Related Questions
drjack9650@gmail.com
Navigate
Integrity-first tutoring: explanations and feedback only — we do not complete graded work. Learn more.