Question: Need help with Exercise 6-3: Enhance the invoice Total application on how to add a GetInvoiceAmounts() method. I'm stuck and not sure where to add

Need help with Exercise 6-3: Enhance the invoice Total application on how to add a GetInvoiceAmounts() method. I'm stuck and not sure where to add it.

1. add a method named getinvoiceamounts() that accepts the customer type and subtotal and returns the discount percent. you can do that manually or using refactoring.

3. test the application to make sure the new method works correctly.

namespace InvoiceTotal { public partial class frmInvoiceTotal : Form { public frmInvoiceTotal() { InitializeComponent(); }

private void btnCalculate_Click(object sender, EventArgs e) { string customerType = txtCustomerType.Text; decimal subtotal = Convert.ToDecimal(txtSubtotal.Text); decimal discountPercent = .0m;

if (customerType == "R") { if (subtotal < 100) discountPercent = .0m; else if (subtotal >= 100 && subtotal < 250) discountPercent = .1m; else if (subtotal >= 250) discountPercent = .25m; } else if (customerType == "C") { if (subtotal < 250) discountPercent = .2m; else discountPercent = .3m; } else { discountPercent = .4m; }

decimal discountAmount = subtotal * discountPercent; decimal invoiceTotal = subtotal - discountAmount;

txtDiscountPercent.Text = discountPercent.ToString("p1"); txtDiscountAmount.Text = discountAmount.ToString("c"); txtTotal.Text = invoiceTotal.ToString("c");

txtCustomerType.Focus(); }

private void btnExit_Click(object sender, EventArgs e) { this.Close(); } } }

Step by Step Solution

There are 3 Steps involved in it

1 Expert Approved Answer
Step: 1 Unlock blur-text-image
Question Has Been Solved by an Expert!

Get step-by-step solutions from verified subject matter experts

Step: 2 Unlock
Step: 3 Unlock

Students Have Also Explored These Related Databases Questions!