Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

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

Step: 1

blur-text-image

Get Instant Access to Expert-Tailored Solutions

See step-by-step solutions with expert insights and AI powered tools for academic success

Step: 2

blur-text-image

Step: 3

blur-text-image

Ace Your Homework with AI

Get the answers you need in no time with our AI-driven, step-by-step assistance

Get Started

Recommended Textbook for

Professional Microsoft SQL Server 2014 Integration Services

Authors: Brian Knight, Devin Knight

1st Edition

1118850904, 9781118850909

More Books

Students also viewed these Databases questions