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

private void btnExit_Click(object sender, EventArgs e) { this.Close(); }

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

Professional Microsoft SQL Server 2014 Administration

Authors: Adam Jorgensen, Bradley Ball

1st Edition

111885926X, 9781118859261

More Books

Students also viewed these Databases questions

Question

2. Compare the sales and service departments at Auto World.

Answered: 1 week ago