Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

Murach's C# 2015 Training & Reference: I need help with both Exercise 4-1. I figured out steps 1-4, but not understanding how to modify the

Murach's C# 2015 Training & Reference: I need help with both Exercise 4-1.

I figured out steps 1-4, but not understanding how to modify the code for 5 & 6.

Code is:

private void btnCalculate_Click(object sender, EventArgs e) { decimal subtotal = Convert.ToDecimal(txtSubtotal.Text); decimal discountPercent = .25m; decimal discountAmount = subtotal * discountPercent; decimal invoiceTotal = subtotal - discountAmount;

txtDiscountPercent.Text = discountPercent.ToString("p1"); txtDiscountAmount.Text = discountAmount.ToString("c"); txtTotal.Text = invoiceTotal.ToString("c");

txtSubtotal.Focus(); }

5. Modify the first statement in the btnCalculate_Click method so it uses the Parse method of the Decimal class instead of the ToDecimal method of the Convert Class. Then, test the application to verify that it still works the same.

6. Round the values that are stored in the discountAmount and invoiceTotal variables to two decimal places, and delete the formatting codes for the statements that covert these variables to strings. Then, test the application to make sure that only two decimal places are displayed for the discount amount and total.

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

Pro SQL Server Administration

Authors: Peter Carter

1st Edition

1484207106, 9781484207109

More Books

Students also viewed these Databases questions

Question

Summarize some human resource management training initiatives.

Answered: 1 week ago

Question

what is a peer Group? Importance?

Answered: 1 week ago