ok heres the assignment my teacher gave me for a intro to vb.net course
Bea Frugal is a careful shopper. She always looks for the specials and coupons before making any purchases, and she keeps records of the amount of money she has saved. After a day of shopping, Bea manually adds up the coupons and discount amounts she has accumulated that day and records it in a book. She would also like to record total purchases for the day and the percentage of her savings over cost but would like to use her computer to do the work. Design and implement an application that will provide Bea with the totals she desires. As the number of transactions will vary from trip to trip, the application should request the number of transactions to be entered. Collect the paid amount and the coupon or discount amount for each transaction. Sum the amounts, calculate the savings percent and display the total purchase price (paid plus discount), the total discount amount (savings), the percentage of savings over total cost, and the total amount paid. Use a Sub procedure to collect and sum the totals, passing the total variables by reference; use a Function to calculate and return the savings percentage (pass the total cost and savings by value), and a Sub procedure to display the results (pass all totals and percentage by value). The interface should contain output labels for each total (display as currency) and one for savings percent (display as a percentage). Provide two buttons: one to allow a new set of transactions (reset) and one to exit the application. Use all of the techniques you have learned to ensure proper input handling. Name the project and solution "Coupons."
i think its a bit tuff for a intro course and pls dont badger me for being a bad student...seriously all he does is read of his powerpoint for 3 hours and now im in danger of failing the class and im panicking
i spent about 5 or 6 hours on this assignment and got absouletly no where and im pulling my hair out pls help!!
heres the code for it so far... as u can see i am having immense trouble coding it to sum the totals of the collection i have a add button to add each text entry to the collectino and then a calc button to calculate once all entrys to the collection have been entered its easy wen its like me.ampt textbox.text + me.ampttext...blah blah but i cant figure out how to add the totals together wen they in collection pls help
CODE
Public Class Form1
Dim purchases As Collection
Dim item As aClass
Private Sub xResetButton_Click(ByVal sender As Object, ByVal e As System.EventArgs) Handles xResetButton.Click
Me.xNumofTransTextbox.Text = String.Empty
Me.xNumofTransTextbox.Focus()
End Sub
Private Sub xExitButton_Click(ByVal sender As Object, ByVal e As System.EventArgs) Handles xExitButton.Click
Me.Close()
End Sub
Private Sub xNumofTransTextbox_Click(ByVal sender As Object, ByVal e As System.EventArgs) Handles xNumofTransTextbox.Click
Me.xNumofTransTextbox.Focus()
Me.xNumofTransTextbox.SelectAll()
End Sub
Private Sub xNumofTransTextbox_KeyPress(ByVal sender As Object, ByVal e As System.Windows.Forms.KeyPressEventArgs) Handles xNumofTransTextbox.KeyPress
If (e.KeyChar < "0" OrElse e.KeyChar > "9") _
AndAlso e.KeyChar <> ControlChars.Back Then
e.Handled = True
End If
End Sub
Private Sub Form1_Load(ByVal sender As Object, ByVal e As System.EventArgs) Handles Me.Load
purchases = New Collection
End Sub
Private Function GetSavingPercentage(ByVal totalcost As Decimal, ByVal savings As Decimal)
Dim total As Decimal
Dim discount As Decimal
End Function
Private Sub xEnterButton_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles xEnterButton.Click
Dim numberofitems As Integer
Integer.TryParse(Me.xNumofTransTextbox.Text, numberofitems)
End Sub
Private Sub xTotalPaidTextbox_KeyPress(ByVal sender As Object, ByVal e As System.Windows.Forms.KeyPressEventArgs) Handles xTotalPaidTextbox.KeyPress
If (e.KeyChar < "0" OrElse e.KeyChar > "9") _
AndAlso e.KeyChar <> ControlChars.Back _
AndAlso e.KeyChar <> "." Then
e.Handled = True
End If
End Sub
Private Sub xDisAmtTextbox_KeyPress(ByVal sender As Object, ByVal e As System.Windows.Forms.KeyPressEventArgs) Handles xDisAmtTextbox.KeyPress
If (e.KeyChar < "0" OrElse e.KeyChar > "9") _
AndAlso e.KeyChar <> ControlChars.Back _
AndAlso e.KeyChar <> "." Then
e.Handled = True
End If
End Sub
Private Sub xAddButton_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles xAddButton.Click
item = New aClass(Me.xTotalPaidTextbox.Text, Me.xDisAmtTextbox.Text)
purchases.Add(item)
End Sub
Private Sub CollectandSumtheTotals(ByVal items As aClass, ByVal total As aClass, ByVal discount As aClass, ByVal numberofitems As Integer)
Dim item As aClass
cint(total as expression) as integer
Dim TotalPaid As aClass = "0"
For Each Total As aClass In purchases
TotalPaid = Total.show
Next
If numberofitems <> items in purchases Then
MsgBox("Error")
End If
Me.xTotSpentLabel.Text = TotalPaid.ToString("C2")
End Sub
End Class
heres the class i came up with or collection or watever
CODE
Public Class aClass
Private total As Integer
Private discount As Integer
Public Sub New(ByVal n As Integer, ByVal d As Integer)
total = n
discount = d
End Sub
Public Function show() As String
Return total.ToString() + "/" + discount.ToString()
End Function
End Class
This post has been edited by Jayman: 1 Dec, 2008 - 09:23 PM