Create an application that determines the final cost of food items and non-food items, assuming only non-food items are taxed. The interface should prompt the user for the total cost of food items and the total cost of non-food items. Display the final cost when an Answer button is clicked. Use a constant for the tax with value of 7%.

Respuesta :

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);

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

Ver imagen MrRoyal
Ver imagen MrRoyal
Ver imagen MrRoyal
ACCESS MORE
EDU ACCESS
Universidad de Mexico