Answer:
Write the following in the button click event:
double total = Convert.ToDouble(txtNonFood.Text) + Convert.ToDouble(txtFood.Text) * (1 + 0.07);
MessageBox.Show("Total: " + total);
Step-by-step explanation:
The app is created using Winforms C#.
First, is to design the form using 2 labels, 2 textboxes and 1 button.
The text of the labels are set to "Food Items" and "Non Food Items", respectively.
The name of the textboxes are set to txtFood and txtNonFood respectively.
Next, is to ensure that the textboxes accept only numbers and 1 decimal point.
So, we need to create a keypress event:
private void txtNonFood_KeyPress(object sender, KeyPressEventArgs e){
And then, write the click event to display the total amount of items (as written in the answer section):
This calculates the total amount
double total = Convert.ToDouble(txtNonFood.Text) + Convert.ToDouble(txtFood.Text) * (1 + 0.07);
This prints the total amount
MessageBox.Show("Total: " + total);
See attachment 1 for app interface & attachments 2 and 3 for complete program code