
c. The output controls (for the Ext. Price values, Subtotal, Sales Tax, and Grand
Total) are
TextBoxes with ReadOnly set to True.
d. Set the form’s AcceptButton property to the Calculate button.
2. Give names to the controls that the program needs to manipulate. That includes the
NumericUpDown controls and all of the TextBoxes except the Item TextBoxes, which
this program doesn’t really use.
When the user clicks the Calculate button, make the program:
Multiply each item’s Quantity value by its Price Each value and display the result in
the corresponding Ext. Price textbox.
Add up the Ext. Price values and display the result in the Subtotal textbox.
Multiply the Subtotal value by the entered Tax Rate and display the result in the
Sales Tax textbox.
Add the Subtotal, Sales Tax, and Shipping values, and display the result in the Grand
Total textbox.
This is easy to do in three steps:
1. Gather input values from the user and store them in variables. Because they are already
numeric, the code doesn’t need to parse the values that come from the
NumericUpDown
control’s
Value properties. The program does need to parse the values in TextBoxes to
convert them into
decimal values.
// Get input values.
decimal quantity1 = quantity1NumericUpDown.Value;
decimal quantity2 = quantity2NumericUpDown.Value;
decimal quantity3 = quantity3NumericUpDown.Value;
decimal quantity4 = quantity4NumericUpDown.Value; ...