VB.NET programming

Discussion in 'Software' started by NYVB, Nov 21, 2006.

  1. NYVB

    NYVB Private E-2

    Hello, I really need your help to complete my assignment Please. The Q. is: Create an application that allows the user to enter a number of pennies. The application then calculates the number of dollars, quarters, dimes, nickels, and pennies that the user would receive if cashed the pennies. I know how to calculate the dollars, but I get confused with the quarters, dimes, ect. The logic would go "divide up into dollars and minus the number of whole dollars from the initial amount, but I still don't how to code it.... I need your help PLEASE! Thank you
     
  2. matt.chugg

    matt.chugg MajorGeek

    This sounds a bit like a homework question so I won't just post the answer ;)

    You might want to look at a modulus() function

     
  3. goldfish

    goldfish Lt. Sushi.DC

    Well, actually, in C++ (and VB.NET) you can do that without using modulus functions OR loops. It makes use of automatic type casting.

    (BTW you missed a bunch of semicolons and a space between #include and <iostream> ;))
     
  4. NYVB

    NYVB Private E-2

    Thank you matt. u are right I have to use Modulus operator, but the problem is, the code works with one # which is the (7333 pennies) and it doesn't work w the second # of pennies which is (2311) :( I already got "0" for this assignment but I really want to know the correct answer or the correct coding, curiosity !

    Thank you Chris, I wish I could use C++ coding but we r not allowed, I must use VB.NET only. It was really nice of u writing the codes. Thanks for your help

    Thank you Goldfish for your help

    wish u all the best
     
  5. matt.chugg

    matt.chugg MajorGeek

    well the code you have shouldn't be too long, why not post it and i'll take a look at it.

    remember to put it in [noparse]
    Code:
    
    
    [/noparse] blocks.
     
  6. NYVB

    NYVB Private E-2

    Thank u matt for your help ..... I know I have to use either integer or Mod and not both at the same time this way :
    intDollars = intPennies \ 100
    intPennies = intPennies Mod (100)
    intQuarters = intPennies \ 25
    etc.... but for some reason it's not working

    This is how I did it.

    'declare variables
    Dim intDollar As Integer
    Dim intQuarters As Integer
    Dim intInputPennies As Integer
    Dim intDimes As Integer
    Dim intNickels As Integer
    Dim intPennies As Integer

    'Assign values to the variables
    intDollar = Val(Me.uiDollarsLabel.Text)
    intQuarters = Val(Me.uiQuarterLabel.Text)
    intInputPennies = Val(Me.uiTotPenniesTextBox.Text)
    intDimes = Val(Me.uiDimeLabel.Text)
    intNickels = Val(Me.uiNickelLabel.Text)
    intPennies = Val(Me.uiPennieLabel.Text)

    'perform calculation
    intDollar = intInputPennies \ 100
    intQuarters = intInputPennies Mod 100 / 25
    intDimes = intInputPennies Mod 100 / 25 / 10
    intNickels = intInputPennies Mod 10 / 5
    intPennies = intInputPennies Mod 5 /1

    'display total ammounts in controls
    Me.uiDollarsLabel.Text = intDollar
    Me.uiQuarterLabel.Text = intQuarters
    Me.uiDimeLabel.Text = intDimes
    Me.uiNickelLabel.Text = intNickels
    Me.uiPennieLabel.Text = intPennies

    End Sub

    Thank u matt.
     
  7. NYVB

    NYVB Private E-2

    hi matt, finally I did it,,, I think it's right,, check it please:) I thought of every possible way and I did it....Thanks matt

    'perform calculation
    intDollar = intInputPennies \ 100
    intPennies = intInputPennies Mod (100)
    intQuarters = intInputPennies Mod (25)
    intQuarters = intPennies \ 25
    intPennies = intInputPennies Mod (25)
    intDimes = intInputPennies Mod (10)
    intDimes = intPennies \ 10
    intPennies = intPennies Mod (10)
    intNickels = intInputPennies Mod (5)
    intNickels = intPennies \ 5
    intPennies = intPennies Mod (5)
     

MajorGeeks.Com Menu

Downloads All In One Tweaks \ Android \ Anti-Malware \ Anti-Virus \ Appearance \ Backup \ Browsers \ CD\DVD\Blu-Ray \ Covert Ops \ Drive Utilities \ Drivers \ Graphics \ Internet Tools \ Multimedia \ Networking \ Office Tools \ PC Games \ System Tools \ Mac/Apple/Ipad Downloads

Other News: Top Downloads \ News (Tech) \ Off Base (Other Websites News) \ Way Off Base (Offbeat Stories and Pics)

Social: Facebook \ YouTube \ Twitter \ Tumblr \ Pintrest \ RSS Feeds