Welcome to Dream.In.Code
Getting VB.NET Help is Easy!

Join 136,562 VB.NET Programmers for FREE! Get instant access to thousands of VB.NET experts, tutorials, code snippets, and more! There are 1,903 people online right now. Registration is fast and FREE... Join Now!




Help with Assignment

 
Reply to this topicStart new topic

Help with Assignment

muscle
13 Apr, 2008 - 04:37 PM
Post #1

New D.I.C Head
*

Joined: 13 Apr, 2008
Posts: 4

This is the assignment: An internet service provider offers three subscription packages plus a discount fo nonprofit organizations.
a. Package A: 10 hours of access for $9.95 per month. Additional hours are $2.00 per hour.
b. Package B: 20 hours of access for $14.95 per month. Additonal hours are $1.00 per hour.
c. PackageC: Unlimited access for $19.95 per month.
d. Nonprofit Organizations: THe service provider gives all nonprofit organizations a 20 % discount on all packages.
The user should select a package the customer has purchased (from a set of radio buttons) and enter the number of hours used. A check box captioned Nonprofit should also appear on the form. The application should calculate and display the total amount due. If user selects Nonprofit organization check box, a 20% discount should be deducted.
Input validation: the number of hours used in a month cannot exceed 744. The value must be numeric.

vb

Public Class Form1

Private Sub Button1_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button1.Click
'Declare
Dim PackageA As Decimal 'Package A base price
Dim PackageB As Decimal 'Package B base price
Dim PackageC As Integer 'Package C base price
Dim Hours As Decimal '# of hours in each Package
Dim Price As Integer
Dim Additional As Integer 'Additional cost over hours
Dim Total As Integer 'Total package price
'The following constants are used to calculate discounts.
'Discount can be used for package A, B, or C.
Dim Nonprofit As Decimal = 0.2D '20 %
'Calculate the base package price
If radA.Checked = True Then
PackageA = 9.95
lblTotal.Text = FormatCurrency(PackageA)
ElseIf Hours > 10 Then
Additional += 2.0
lblTotal.Text = (PackageA)
End If
If RadB.Checked = True Then
PackageB = 14.95
lblTotal.Text = FormatCurrency(PackageB)
End If

If RadC.Checked = True Then
PackageC = 19.95
lblTotal.Text = FormatCurrency(PackageC)
End If

'# of hours used in each package


'Determine the discount, based nonprofit organization
If radA.Checked And ChkNonprofit.Checked = True Then
Price = PackageA * Nonprofit
lblTotal.Text = FormatCurrency(PackageA - 1.99)
ElseIf RadB.Checked And ChkNonprofit.Checked = True Then
Price = 14.95 - 0.2
lblTotal.Text = FormatCurrency(PackageB - 2.99)
ElseIf RadC.Checked And ChkNonprofit.Checked = True Then
lblTotal.Text = FormatCurrency(PackageC - 3.99)
End If


'Display the Total


End Sub

Private Sub Button2_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button2.Click
Me.Close()
End Sub
End Class


EDIT: Code blocks added smile.gif

This post has been edited by PsychoCoder: 13 Apr, 2008 - 04:39 PM
User is offlineProfile CardPM
+Quote Post

PsychoCoder
RE: Help With Assignment
13 Apr, 2008 - 04:40 PM
Post #2

using DIC.Core;
Group Icon

Joined: 26 Jul, 2007
Posts: 8,997



Thanked: 125 times
Dream Kudos: 8625
Expert In: VB, VB.Net, C#, SQL, ASP, ASP.Net, Web Development, HTML, CSS, Win32 API, Javascript, mySQL, J#, Boo.Net

My Contributions
Well we need to know what you're having a problem with, are you getting an error (if so what is it), what is this code not doing that you need it to do? These are vital pieces of information we need in order to help smile.gif

Also, this is VB.Net code so Im moving it to the VB.Net Forum smile.gif
User is offlineProfile CardPM
+Quote Post

muscle
RE: Help With Assignment
13 Apr, 2008 - 04:50 PM
Post #3

New D.I.C Head
*

Joined: 13 Apr, 2008
Posts: 4

QUOTE(PsychoCoder @ 13 Apr, 2008 - 05:40 PM) *

Well we need to know what you're having a problem with, are you getting an error (if so what is it), what is this code not doing that you need it to do? These are vital pieces of information we need in order to help smile.gif

Also, this is VB.Net code so Im moving it to the VB.Net Forum smile.gif



I can't get the hours , additional cost past base hours, or the discount to work. The only thing I have working is the base package prices.
User is offlineProfile CardPM
+Quote Post

JasonDurso
RE: Help With Assignment
13 Apr, 2008 - 05:23 PM
Post #4

New D.I.C Head
*

Joined: 29 Mar, 2008
Posts: 19



Thanked: 1 times
My Contributions
I am a beginner at coding but try this

CODE


Public Class Form1
    'Declare Variables
    Dim PackageA As Decimal
    Dim PackageB As Decimal
    Dim PackageC As Integer
    Dim Hours As Decimal
    Dim Price As Integer
    Dim Additional As Integer
    Dim Total As Integer
    Dim Nonprofit As Decimal



    Private Sub Button1_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button1.Click

        ' Fill Variables with Data
        Additional = 0
        PackageA = 9.95
        PackageB = 14.95
        PackageC = 19.95
        Nonprofit = 0.2

        'Calculate the price and Display
        If radA.Checked = True Then
            lblTotal.Text = PackageA.ToString("C2")


        ElseIf rada.Checked = True And Hours > 10 Then
            Additional = 2.0 * Hours > 10
            Total = Additional + PackageA
            lblTotal.Text = Total.ToString("C2")
        End If

        If RadB.Checked = True Then
            lblTotal.Text = PackageB.ToString("C2")


        ElseIf RadB.Checked = True And Hours > 10 Then
            Additional = 1.0 * Hours > 10
            Total = Additional + PackageB
            lblTotal.Text = Total.ToString("C2")
        End If

        If RadC.Checked = True Then
            lblTotal.Text = PackageC.ToString("C2")
        End If


        'Determine the discount, based nonprofit organization  and Display Total
        If radA.Checked And ChkNonprofit.Checked = True Then
            Price = PackageA * Nonprofit
            lblTotal.Text = Price.ToString("C2")

        ElseIf RadB.Checked And ChkNonprofit.Checked = True Then
            Price = PackageB * Nonprofit
            lblTotal.Text = Price.ToString("C2")
        ElseIf RadC.Checked And ChkNonprofit.Checked = True Then
            Price = PackageC * Nonprofit
            lblTotal.Text = Price.ToString("C2")
        End If




    End Sub

    Private Sub Button2_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button2.Click
        Me.Close()
    End Sub
End Class


Hope this helps

Did you need to add hours into the nonprofit organizations?
User is offlineProfile CardPM
+Quote Post

muscle
RE: Help With Assignment
13 Apr, 2008 - 05:42 PM
Post #5

New D.I.C Head
*

Joined: 13 Apr, 2008
Posts: 4

Yes. With the discount the 20% needs to be taken away from Package price and additonal hours. With the code you did the base package prices appeared, but when you put in extra hours the price did not change.
User is offlineProfile CardPM
+Quote Post

JasonDurso
RE: Help With Assignment
13 Apr, 2008 - 06:08 PM
Post #6

New D.I.C Head
*

Joined: 29 Mar, 2008
Posts: 19



Thanked: 1 times
My Contributions
Ok question in your code I did not see anything that filled the variable hours, is this coming from a textbox?
you need to tell the computer to fill the hours variable so something like this

Hours = hoursTextBox.Text
you will need to change the textbox to what ever you named it. I added some code to the non profit part but you still need to assign data to the Hours variable Then try the rest of the code hope it works for you.

CODE

'Declare Variables
    Dim PackageA As Decimal
    Dim PackageB As Decimal
    Dim PackageC As Integer
    Dim Hours As Decimal
    Dim Price As Integer
    Dim Additional As Integer
    Dim Total As Integer
    Dim Nonprofit As Decimal



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

    End Sub
    Private Sub Button1_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button1.Click

        ' Fill Variables with Data
        Additional = 0
        PackageA = 9.95
        PackageB = 14.95
        PackageC = 19.95
        Nonprofit = 0.2
        

        'Calculate the price and Display
        If radA.Checked = True Then
            lblTotal.Text = PackageA.ToString("C2")


        ElseIf rada.Checked = True And Hours > 10 Then
            Additional = 2.0 * Hours > 10
            Total = Additional + PackageA
            lblTotal.Text = Total.ToString("C2")
        End If

        If RadB.Checked = True Then
            lblTotal.Text = PackageB.ToString("C2")


        ElseIf RadB.Checked = True And Hours > 10 Then
            Additional = 1.0 * Hours > 10
            Total = Additional + PackageB
            lblTotal.Text = Total.ToString("C2")
        End If

        If RadC.Checked = True Then
            lblTotal.Text = PackageC.ToString("C2")
        End If


        'Determine the discount, based nonprofit organization  and Display Total
        If radA.Checked And ChkNonprofit.Checked = True Then
            Additional = 2.0 * Hours > 10
            Price = PackageA * Nonprofit
            Total = Additional + Price
            lblTotal.Text = Total.ToString("C2")

        ElseIf RadB.Checked And ChkNonprofit.Checked = True Then
            Additional = 1.0 * Hours > 10
            Price = PackageB * Nonprofit
            Total = Additional + Price
            lblTotal.Text = Total.ToString("C2")

        ElseIf RadC.Checked And ChkNonprofit.Checked = True Then
            Price = PackageC * Nonprofit
            lblTotal.Text = Price.ToString("C2")
        End If




    End Sub

    Private Sub Button2_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button2.Click
        Me.Close()
    End Sub
End Class



User is offlineProfile CardPM
+Quote Post

Fast ReplyReply to this topicStart new topic
Time is now: 12/2/08 11:42PM

Live VB.NET Help!

VB.NET Tutorials

Reference Sheets

VB.NET Snippets

DIC Chatroom

Bye Bye Ads

Monthly Drawing

Thumb Drive

Top Contributors

Top 10 Kudos This Month