Question
Hello, I'm having a very tough time completing excercise 8-1 in this visual basic book. The question is below and the code I have to
Hello,
I'm having a very tough time completing excercise 8-1 in this visual basic book. The question is below and the code I have to work with is as follows:
Public Class frmInvoiceTotal
Private Sub btnCalculate_Click(sender As Object, e As EventArgs) Handles btnCalculate.Click Dim subtotal As Decimal = CDec(txtSubtotal.Text) Dim discountPercent As Decimal Dim discountamount As Decimal = subtotal * discountPercent Dim invoicetotal As Decimal = subtotal - discountamount Dim totals() As Integer = {120, 150, 175, 225, 275} Dim pointer As Integer = 0
Exit Sub
If txtCustomerType.Text = "R" Then If subtotal = 100 AndAlso subtotal = 250 Then discountPercent = 0.25D End If ElseIf txtCustomerType.Text = "C" Then If subtotal
txtDiscountPercent.Text = FormatPercent(discountPercent, 1) txtDiscountAmount.Text = FormatCurrency(discountAmount) txtTotal.Text = FormatCurrency(invoiceTotal)
txtCustomerType.Select() End Sub
Private Sub btnExit_Click(sender As Object, e As EventArgs) Handles btnExit.Click Me.Close() End Sub
End Class
Any help would be greatly appreciated!
Thanks
Add code that displays all the invoice totals in the array in a message box when the user clicks t through the totals and format the message for the message box Test the program by entering three invoices and then clicking the Exit button. This should display a dialog box like the one that follows. But note that the fourth and fifth elements in the array are also displayed because they were initialized with zero values Perspective he Exit button. To do that, use a For Each loop to loop In this chapter, you've learned how to use both arrays and collect for working with groups of related data. You've also learned that the NET Framework provides typed classes that offer use working with colloctions. These include the List), SortedList) Stack) classes. 5. ful properties and methods for . Queue0, and As you develop your own applications, you often need to decide bet the use of an array or collection. Then, if you decide to use a collection, you need to choose the mest appropriate type of collection. If you make the right decisions, your code will be easier to write, debug, and maintain. ween Order Tatals Ar 513030 19200 $0.00 Terms typed collection generics untyped collection list collection initializer sorted list key/value pair queue stack first-in, first-out (FIFO) last-in, first-out (LIFO) array one-dimensional array element upper bound length 6. Fix this problem by adding an If statement to the For Each loop that ignores any array elements that are equal to zero. Then, test the program to make sure that it works. 7. Test the program by entering more than five invoices. When you do, an For Each statement For Each loop rectangular array two-dimensional array IndexOutOfRangeException should be thrown. Sort the invoice totals 8. Add code to sort the invoice totals in the array 9. Test the program again to be sure that the message box displays the invoice boxing unboxing totals in the correct sequence. Modify the program so it uses a list 10. Without changing any of the current code, add code that uses the List) class array ot arrays null-conditional operator collection to hold the invoice totals. Then, when the user clicks the Exit button, sort the list elements and add a second For Each loop to format and display the totals stored in the list in a second message box. In other words, display two Exercise 8-1 Use an array and a list This exercise will guide you through the process of adding an array and a list to message boxes: one for the array and one for the list. 11. When you've got this working right, close the solutio the Invoice Total application that you saw in chapter 5 Open the Invoice Total application 1. Open the application that's in the CAVB 2015 Chapter 08 Invoice Tota Exercise 8-2 Use a rectangular array directory Use an array to store invoice totals 2. Declare two module-level variables: (I) an array that can hold up to five This exercise will guide you through the process of adding a rectangular array to the Future Value application that you saw in chapter 7. This array will store the values for each calculation that's performed. invoice totals and (2) an index that you can use to work with that array Add code that adds the invoice total to the next element in the array each time the user clicks the Calculate button. Open the Future Value application 3. Open the application that's in the CAVB 2015)1Chapter 08 Future ValueStep by Step Solution
There are 3 Steps involved in it
Step: 1
Get Instant Access to Expert-Tailored Solutions
See step-by-step solutions with expert insights and AI powered tools for academic success
Step: 2
Step: 3
Ace Your Homework with AI
Get the answers you need in no time with our AI-driven, step-by-step assistance
Get Started