Howdy, Stranger!

It looks like you're new here. If you want to get involved, click one of these buttons!

Categories

Welcome to the new platform of Programmer's Heaven! We apologize for the inconvenience caused, if you visited us from a broken link of the previous version. The main reason to move to a new platform is to provide more effective and collaborative experience to you all. Please feel free to experience the new platform and use its exciting features. Contact us for any issue that you need to get clarified. We are more than happy to help you.

Need some Help on My Homework

tastybrowniestastybrownies Posts: 6Member
The title says it, I need a little help on my homework. I feel I have most of the code, but I keep missing something over and over. The program runs, but there is a logic error.

Let me put what the problem says and then I'll paste my code.

Lynette Rifle owns an image consulting shop. Her clients can select from the following services at the specified regular prices: Makeover $125, Hair Styling $60, Manicure $35, and the Permanent Makeup $200. She has distrubted discount coupons that advertise discounts of 10 percent and 20 percent off the regular price. Create a project that will allow the receptionist to select a discount rate of 10 percent, 20 percent, or none, and then select a service. Display the price for the individual service and the total due after each visit is completed. A visit may include several services. Include buttons for calculate, clear, and exit.

I think I am right in stating that they don't want any summary boxes.
Here is the code I have, hopfully it's not that much off.

[code]'Program Name: Chapt4salon
'Programmer: Justin
'Date: April 2008
'Description: This project calculates information from an image consulting shop.
' It takes the prices from makeovers, permanent makeup, hair styling
' and other and gives them a discount either 0%, 10%, or 20%.

Public Class imageConsultForm
'Declare the Constants.
Const PERMANENT_MAKEUP_INTEGER As Integer = 200I
Const MAKEOVER_INTEGER As Integer = 125I
Const HAIR_STYLING_INTEGER As Integer = 60I
Const MANICURE_INTEGER As Integer = 35I
Private pricePerServiceDecimal As Decimal
Private totalPriceDecimal As Decimal


Private Sub calculateButton_Click(ByVal sender As System.Object, _
ByVal e As System.EventArgs) Handles calculateButton.Click
'Calculate and display the totals and amounts including discounts.

Dim quantityInteger As Integer
Dim itemAmountDecimal As Decimal
Const TEN_PERCENT_DECIMAL As Decimal = 0.1
Const TWENT_PERCENT_DECIMAL As Decimal = 0.2

With Me

'Finding the price for each choice.
If .permanentMakeupRadioButton.Checked Then
pricePerServiceDecimal = PERMANENT_MAKEUP_INTEGER
ElseIf .makeoverRadioButton.Checked Then
pricePerServiceDecimal = MAKEOVER_INTEGER
ElseIf .hairStylingRadioButton.Checked Then
pricePerServiceDecimal = HAIR_STYLING_INTEGER
ElseIf .manicureRadioButton.Checked Then
pricePerServiceDecimal = MANICURE_INTEGER
End If





'Calculate the price and total with discounts.
Try
quantityInteger = Integer.Parse(.quantityTextBox.Text)
itemAmountDecimal = pricePerServiceDecimal * quantityInteger
totalPriceDecimal += itemAmountDecimal
If .tenPerDiscountRadioButton.Checked Then
pricePerServiceDecimal = (itemAmountDecimal) - itemAmountDecimal * TEN_PERCENT_DECIMAL
ElseIf .twentPerDiscountRadioButton.Checked Then
pricePerServiceDecimal = (itemAmountDecimal) - itemAmountDecimal * TWENT_PERCENT_DECIMAL
ElseIf .noDiscountRadioButton.Checked Then
pricePerServiceDecimal = (itemAmountDecimal)
End If
.priceServiceTextBox.Text = pricePerServiceDecimal.ToString("C")
.priceTotalTextBox.Text = totalPriceDecimal.ToString("C")
'Allow clear after an order has already began.


Catch quantityException As FormatException
MessageBox.Show("Quantity must be numeric.", _
"Data Entry Error", MessageBoxButtons.OK, _
MessageBoxIcon.Error)
With .quantityTextBox
.Focus()
.SelectAll()
End With
End Try
End With
End Sub


Private Sub clearButton_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles clearButton.Click
'Clear the appropriate fields.
With Me
.tenPerDiscountRadioButton.Checked = True 'All other buttons are false.
.permanentMakeupRadioButton.Checked = True 'All other buttons are false.
With .quantityTextBox
.Clear()
.Focus()
End With
End With
End Sub


Private Sub exitButton_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles exitButton.Click
'Exit the program.

Me.Close()
End Sub
End Class[/code]



Comments

  • molyU2BabemolyU2Babe Posts: 2Member
    This is what I have so far and it is not doing the calculations as I want it to do. Any advice, direction, help is much appreciated!


    Public Class ImageShopForm
    ' Declare Constants.

    Const TEN_PERCENT_DECIMAL As Decimal = 10D
    Const TWENT_PERCENT_DECIMAL As Decimal = 20D
    Const PERMANENT_MAKEUP_DECIMAL As Decimal = 200D
    Const MAKEOVER_DECIMAL As Decimal = 125D
    Const HAIR_STYLING_DECIMAL As Decimal = 60D
    Const MANICURE_DECIMAL As Decimal = 35D

    Private Sub Form1_Load(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MyBase.Load

    End Sub

    Private Sub Button4_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles ExitButton.Click
    ' Exit the program.

    Me.Close()
    End Sub

    Private Sub PrintButton_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles PrintButton.Click
    ' Print the form.

    PrintForm1.PrintAction = Printing.PrintAction.PrintToPreview
    PrintForm1.Print()

    End Sub

    Private Sub ClearButton_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles ClearButton.Click
    ' Clear some fields.

    With Me
    .TenPerDiscountRadioButton.Checked = True ' Other buttons are false.
    .PermanentMakeupRadioButton.Checked = True ' Other buttons are false.
    With .QuantityTextBox
    .Clear()
    .Focus()
    End With
    End With
    End Sub

    Private Sub CalculateButton_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles CalculateButton.Click
    ' Calculate, display totals, amounts, discounts.

    Dim QuantityInteger As Integer
    Dim PricePerServiceDecimal, TotalPriceDecimal As Decimal



    ' Find price for choice made.
    If PermanentMakeupRadioButton.Checked Then
    PricePerServiceDecimal = PERMANENT_MAKEUP_DECIMAL
    ElseIf MakeoverRadioButton.Checked Then
    PricePerServiceDecimal = MAKEOVER_DECIMAL
    ElseIf HairStylingRadioButton.Checked Then
    PricePerServiceDecimal = HAIR_STYLING_DECIMAL
    ElseIf ManicureRadioButton.Checked Then
    PricePerServiceDecimal = MANICURE_DECIMAL
    End If


    ' Calculate price plus total with discounts.
    Try
    QuantityInteger = Integer.Parse(QuantityTextBox.Text)
    TotalPriceDecimal += PricePerServiceDecimal
    PricePerServiceDecimal = PricePerServiceDecimal * QuantityInteger - TotalPriceDecimal


    If TenPerDiscountRadioButton.Checked Then
    PricePerServiceDecimal = QuantityInteger * TEN_PERCENT_DECIMAL
    ElseIf TwentPerDiscountRadioButton.Checked Then
    PricePerServiceDecimal = QuantityInteger * TWENT_PERCENT_DECIMAL
    ElseIf NoDiscountRadioButton.Checked Then
    PricePerServiceDecimal = 0
    End If
    PriceServiceTextBox.Text = PricePerServiceDecimal.ToString("C")
    PriceTotalTextBox.Text = TotalPriceDecimal.ToString("C")

    ' Allow clear after order has started.
    Catch QuantityException As FormatException
    MessageBox.Show("Quantity must be numeric.", _
    "Data Entry Error", MessageBoxButtons.OK, _
    MessageBoxIcon.Error)
    With QuantityTextBox
    .Focus()
    .SelectAll()
    End With
    End Try

    End Sub
    End Class
Sign In or Register to comment.