Answered step by step
Verified Expert Solution
Question
1 Approved Answer
Using murach's c#Use an array to store invoice totals Declare two class variables: ( 1 ) an array that can hold up to five invoice
Using murach's c#Use an array to store invoice totals
Declare two class variables: an array that can hold up to five invoice totals
and 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.
Add code that displays all the invoice totals in the array in a message box
when the user clicks the Exit button. To do that, use a foreach loop to loop
through the totals and format the message for the message box. Within this
loop, you should include an if statement so you only display totals that are not
equal to zero.
Test the program by entering subtotals for up to five invoices and then
clicking the Exit button. This should display a dialog box like this one:
Test the program by entering more than five invoices. When you do an
IndexOutOfRangeException should be thrown. Then, modify the trycatch
statement so it handles this exception.
Sort the invoice totals
Add code to sort the invoice totals in the array.
Test the program again to be sure that the message box displays the invoice
totals in the correct sequence.
Modify the program so it uses a list
Without changing any of the current code, repeat steps through but use a
list to hold the totals and add a second foreach loop to format and display the
totals stored in the list in a second message box. In other words, display two
message boxes: one for the array and one for the list.
When you've got this working right, close the solution.
Step 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