You are on page 1of 4

Module Module1

Sub Main()
Dim i As Integer
Console.WriteLine("Welcome to Sack Record")
Console.WriteLine("How many transactions you want to make?")
i = Console.ReadLine()
Dim j As Integer
Dim a(i) As Integer
Dim count As Integer
Dim count1 As Integer
Dim valid As Integer
Dim sandweight(i) As Double
Dim cementweight(i) As Double
Dim gravelweight(i) As Double
Dim TotalWeight(i) As Double
Dim Totalsandweight(i) As Double
Dim Totalgravelweight(i) As Double
Dim Totalcementweight(i) As Double
Dim acceptedcementcount(i) As Integer
Dim rejectedcementcount(i) As Integer
Dim acceptedgravelcount(i) As Integer
Dim rejectedgravelcount(i) As Integer
Dim acceptedsandcount(i) As Integer
Dim rejectedsandcount(i) As Integer
Dim Totalcost(i) As Integer
Dim valid2 As Integer
Dim remainingpacks(i) As Integer
Dim specialpack(i) As Integer
Dim remainingcementcount(i) As Integer
Dim remaininggravelcount(i) As Integer
Dim remainingsandcount(i) As Integer
Dim remainingsackcost(i) As Integer
Dim specialpackcost(i) As Integer
Dim finalcost(i) As Integer
Dim savedcost(i) As Integer
For count = 1 To i
Console.WriteLine("How many orders you want to place for single cust
omer?")
j = Console.ReadLine()
Console.WriteLine("Press 1 for C-Cement")
Console.WriteLine("Press 2 for G-Gravel")
Console.WriteLine("Press 3 for S-Sand")
For count1 = 1 To j
Console.WriteLine("Choose transaction")
a(count) = Console.ReadLine()
If (a(count) = 1) Then
valid = 0
Do Until valid = 1
Console.WriteLine("Enter weight of C-Cement")
cementweight(count) = Console.ReadLine()
If cementweight(count) > 24.9 And cementweight(count) <
25.1 Then
Console.WriteLine("Sack Accepted. Sack contain Sand
and Weight of the sack is " & cementweight(count) & ".")
Totalcementweight(count) = Totalcementweight(count)

+ cementweight(count)
acceptedcementcount(count) = acceptedcementcount(cou
nt) + 1
valid = 1
ElseIf (cementweight(count) <= 24.9) Then
rejectedcementcount(count) = rejectedcementcount(cou
nt) + 1
Console.WriteLine("Under Weight")
Else
rejectedcementcount(count) = rejectedcementcount(cou
nt) + 1
Console.WriteLine("Over weight")
End If
Loop
End If
If (a(count) = 2) Then
valid = 0
Do Until valid = 1
Console.WriteLine("Enter weight of G-Gravel")
gravelweight(count) = Console.ReadLine()
If gravelweight(count) > 49.9 And gravelweight(count) <
50.1 Then
Console.WriteLine("Sack Accepted. Sack contain Sand
and Weight of the sack is " & gravelweight(count) & ".")
Totalgravelweight(count) = Totalgravelweight(count)
+ gravelweight(count)
acceptedgravelcount(count) = acceptedgravelcount(cou
nt) + 1
valid = 1
Else
Console.WriteLine("You entered invalid weight, pleas
e try again.")
rejectedgravelcount(count) = rejectedgravelcount(cou
nt) + 1
End If
Loop
End If
If (a(count) = 3) Then
valid = 0
Do Until valid = 1
Console.WriteLine("Enter weight for S-Sand")
sandweight(count) = Console.ReadLine()
If sandweight(count) > 49.9 And sandweight(count) < 50.1
Then
Console.WriteLine("Sack Accepted. Sack contain Sand
and Weight of the sack is " & sandweight(count) & ".")
Totalsandweight(count) = Totalsandweight(count) + sa
ndweight(count)
acceptedsandcount(count) = acceptedsandcount(count)
+ 1
valid = 1
Else
Console.WriteLine("You entered invalid weight, pleas
e try again.")
rejectedsandcount(count) = rejectedsandcount(count)
+ 1

End If
Loop
End If
Next count1
Next count
For count = 1 To i
TotalWeight(count) = Totalcementweight(count) + Totalgravelweight(co
unt) + Totalsandweight(count)
Totalcost(count) = acceptedcementcount(count) * 3 + acceptedgravelco
unt(count) * 2 + acceptedsandcount(count) * 2
Console.WriteLine("Total cost for customer " & count & " is " & Tota
lcost(count) & ".")
Console.WriteLine("Total weight for customer " & count & " is " & To
talWeight(count) & ".")
Console.WriteLine("Total weight for customer " & count & " is " & To
talWeight(count) & ".")
Console.WriteLine("Total sand weight for customer " & count & " is "
& Totalsandweight(count) & ".")
Console.WriteLine("Total gravel weight for customer " & count & " is
" & Totalgravelweight(count) & ".")
Console.WriteLine("Total cement weight for customer " & count & " is
" & Totalcementweight(count) & ".")
Console.WriteLine("Total accepted sacks of sand for customer " & cou
nt & " are " & acceptedsandcount(count) & ".")
Console.WriteLine("Total accepted sacks of gravel for customer " & c
ount & " are " & acceptedgravelcount(count) & ".")
Console.WriteLine("Total accepted sacks of cement for customer " & c
ount & " are " & acceptedcementcount(count) & ".")
Console.WriteLine("Total rejected sacks of sand for customer " & cou
nt & " are " & rejectedsandcount(count) & ".")
Console.WriteLine("Total rejected sacks of gravel for customer " & c
ount & " are " & rejectedgravelcount(count) & ".")
Console.WriteLine("Total rejected sacks of cement for customer " & c
ount & " are " & rejectedcementcount(count) & ".")
If (acceptedcementcount(count)
>= 2) And (acceptedsandcount(count) >= 2)
acceptedcementcount(count)
acceptedgravelcount(count)
acceptedsandcount(count) =

>= 1) And (acceptedgravelcount(count)


Then
= acceptedcementcount(count) - 1
= acceptedgravelcount(count) - 2
acceptedsandcount(count) - 2

specialpack(count) = specialpack(count) + 1
remainingsandcount(count) = acceptedsandcount(count)
remaininggravelcount(count) = acceptedgravelcount(count)
remainingcementcount(count) = acceptedcementcount(count)
End If
Next
For count = 1 To i
specialpackcost(count) = specialpack(i) * 10
remainingsackcost(count) = remainingcementcount(count) * 3 + remaini
nggravelcount(count) * 2 + remainingsandcount(count) * 2
finalcost(count) = specialpackcost(count) + remainingsackcost(count)
savedcost(count) = Totalcost(count) - finalcost(count)
Console.WriteLine("Total final cost for customer " & count & " is "
& finalcost(count) & ".")
Console.WriteLine("Total saved cost for customer " & count & " is "

& savedcost(count) & ".")


Next
Console.ReadLine()
End Sub
End Module

Related Interests