Question: a software company sells a package that retails for $99. quantity discounts are given according to the following table: quantity discount 10-19 20% 20-49 30%
a software company sells a package that retails for $99.
quantity discounts are given according to the following table: quantity discount
10-19 20%
20-49 30%
50-99 40%
100 or more 50%
create an appliccation that lets the user enter the number of packages purchased. the program should thenm display the amount of the discount(if any) and the total amount of the purchase after the discount.
C# Important Part ""Windows Form application"
I have two buttons(calculateButton and exitButton) and a TextBox(quantityTextBox) for inserting the quantity.
Need to have a MessageBox to pop up with info,
I Have this much
using System; using System.Windows.Forms; namespace EE.WinForms { public partial class Form2 : Form { public Form2() { InitializeComponent(); } private void btnCalculate_Click(object sender, EventArgs e) { try { int packagesPurchased = 0; int.TryParse(txtPackagesPurchased.Text, out packagesPurchased); if (packagesPurchased > 0) { decimal totalWithoutDiscount = 99 * packagesPurchased;
int discountPercentage = ReturnDiscount(packagesPurchased);
txtDiscountPercentage.Text = string.Format("{0}%", discountPercentage);
decimal totalWithDiscount = totalWithoutDiscount * ((decimal) discountPercentage / 100);
txtTotalWithDiscount.Text = string.Format("{0:C}", totalWithDiscount); } else { MessageBox.Show("You need to purchase more than 0 packages", "Purchasing Error", MessageBoxButtons.OK, MessageBoxIcon.Information); } } catch (Exception ex) { } } private int ReturnDiscount(int packagesPurchased) { int discount = 0; if (packagesPurchased >= 100) { discount = 50; } else if (packagesPurchased >= 50) { discount = 40; } else if (packagesPurchased >= 20) { discount = 30; } else if (packagesPurchased >= 10) { discount = 20; } return discount; } } }
Can't Figure out how to
How do you show the price after discount, the the total discount, and the percent bracket the purchase falls into in a MessageBox?
Step by Step Solution
There are 3 Steps involved in it
Get step-by-step solutions from verified subject matter experts
