Question: Can some one verify why my code is not working? (Microsoft Visual Basic) The original code is as follows, and it worked perfect. The errors

Can some one verify why my code is not working? (Microsoft Visual Basic)

The original code is as follows, and it worked perfect. The errors are while trying to modify it with the Student edition and the 20% coupon. Below, I will provide the original code and the modified code (bad code).

I have built the interface and I think I labeled all rad and chk boxes correctly. I have also the label for Price (lblPrice).

"Santini Compay sells a software package that is available in two editions: Ultimate and Professional. The Ultimate edition retails for $875.99, and the Professional retails for $499.99. Some customers may have a cupon worth 10% off the proce of the Ultimate edition. The manager wants a program that displays the proce of the edition a customer wants to purchase"

code for the above requirement (good code):

' Name: Modified Santini Project ' Purpose: Display the price of a software package ' Programmer: Victor M. Figueroa on 7 Jun 2018

Public Class frmMain

Private Sub btnExit_Click(sender As Object, e As EventArgs) Handles btnExit.Click Me.Close() End Sub

Private Sub btnGetPrice_Click(sender As Object, e As EventArgs) Handles btnGetPrice.Click ' displays the price of a software package

Const dblULTIMATE As Double = 875.99 Const dblPROFESSIONAL As Double = 499.99 Const dblDISC_RATE As Double = 0.1 Dim dblPrice As Double

' determine price If radUltimate.Checked = True Then dblPrice = dblULTIMATE If chkDiscount.Checked = True Then Dim dblDiscount As Double dblDiscount = dblPrice * dblDISC_RATE dblPrice = dblPrice - dblDiscount End If Else dblPrice = dblPROFESSIONAL End If

' display price lblPrice.Text = dblPrice.ToString("C2") End Sub End Class

***************************************************

bad code. modified with the following requirements:

"The company now offers a Student edition that retails for $399.99. In addition, the company has mailed a coupon to a select number of students. The coupon gives them 20% off the price of the Student edition" Also, Ultimate and Professional rates shouldn't have access to the 20% Student's coupon."

Public Class frmMain

Private Sub btnExit_Click(sender As Object, e As EventArgs) Handles btnExit.Click Me.Close() End Sub

Private Sub btnGetPrice_Click(sender As Object, e As EventArgs) Handles btnGetPrice.Click ' displays the price of a software package

Const dblULTIMATE As Double = 875.99 Const dblPROFESSIONAL As Double = 499.99 Const dblSTUDENT As Double = 399.99 Const dblDISC_RATE As Double = 0.1 Const dblSTU_COUPON as Double = 0.2 Dim dblPrice As Double

' determine price

If radUltimate.Checked = True Then dblPrice = dblULTIMATE End if If radStudent.Checked = True Then dblPrice = dblSTUDENT End if If chkDiscount.Checked = True Then Dim dblDiscount As Double dblDiscount = dblPrice * dblDISC_RATE dblPrice = dblPrice - dblDiscount End If If chkCoupon.Checked = True Then Dim dblCoupon As Double dblCoupon = dblPrice * dblSTU_COUPON dblPrice = dblPrice - dblCoupon End If Else dblPrice = dblPROFESSIONAL End If

' display price

lblPrice.Text = dblPrice.ToString("C2") End Sub End Class

Step by Step Solution

There are 3 Steps involved in it

1 Expert Approved Answer
Step: 1 Unlock blur-text-image
Question Has Been Solved by an Expert!

Get step-by-step solutions from verified subject matter experts

Step: 2 Unlock
Step: 3 Unlock

Students Have Also Explored These Related Databases Questions!