i'm a new programmer and i need help


DevX Home    Today's Headlines   Articles Archive   Tip Bank   Forums   

Results 1 to 4 of 4

Thread: i'm a new programmer and i need help

  1. #1
    Join Date
    Feb 2004
    Posts
    1

    Unhappy i'm a new programmer and i need help

    the boss has a large gun that can shot projectilesat various heights. for each shot stunman can either stand still or jump. if he stands still and the shot is height 1 or 2, then he gets hit. if he jumps and the shot is at a height above 2, then he is also hit. Otherwise, he is not hit. Given the height of each shot and a sequence of jumps. how many hits will stunman take.

    the input integer() pattern is the pattern of heights at which the shots are being fired. each element of the pattern between 1 and 7, inclusive. The input string jumps is the sequence of jumps that stunman will attemp, 'J' means jump and 'S' means he will stand still.

    The methopd should return an integer representing the number of times stunman is hit.

    I know the function looks something like this

    Public Function hitTaken(pattern as Integer(),jumps as String)as Integer

    Please help.

    I wouldn't be here if i haven't tried all the other avenues first.
    i've searched the web and books with no luck. i know somewhat what it should look like but can't get it to work.
    Last edited by newbee; 02-06-2004 at 11:48 AM.

  2. #2
    Join Date
    Nov 2003
    Location
    Portland, OR
    Posts
    8,387
    Hi, newbee: If we do your homework for you, how will you learn? Why don't you try to solve the problem first, and ask for help if you get stuck?

    I'll give you a hint: VB's Rnd function can generate a series of random numbers between 1 and 7. Try looking up the function in VB's online help, or searching the Web for examples of how to use the function.
    Phil Weber
    http://www.philweber.com

    Please post questions to the forums, where others may benefit.
    I do not offer free assistance by e-mail. Thank you!

  3. #3
    Join Date
    Nov 2003
    Location
    Alameda, CA
    Posts
    1,737
    I do not think searching the web will help you in this case...

    You have an array of interers, right? For each elements, you have a hit if the value is less then 3 and the guy stay still, or if the value is greater than 2 and the guy jumps. Did I get this straight?
    Now, write a nice for loop for each element of the array (look at ubound and lbound) and implements the above statement using a sequence of if's.
    If you already have the input parameters because someone is passing them to you, you are home free. Otherwise follow Phil suggestion and generate them randomly.
    Because the probabililty that the boss shots low is 2 out of 7, I suggest to jump to survive...

    Everyone was a newbee,
    Marco

  4. #4
    Join Date
    Nov 2003
    Location
    Portland, OR
    Posts
    8,387
    > I know somewhat what it should look like but can't get it to work.

    In that case, why don't you post the code you have and explain how it's not working. Perhaps we can help you find the problem without doing the assignment for you.
    Phil Weber
    http://www.philweber.com

    Please post questions to the forums, where others may benefit.
    I do not offer free assistance by e-mail. Thank you!

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  
HTML5 Development Center
 
 
FAQ
Latest Articles
Java
.NET
XML
Database
Enterprise
Questions? Contact us.
C++
Web Development
Wireless
Latest Tips
Open Source


   Development Centers

   -- Android Development Center
   -- Cloud Development Project Center
   -- HTML5 Development Center
   -- Windows Mobile Development Center