Skip to content
  • Categories
  • Recent
  • Tags
  • Popular
  • World
  • Users
  • Groups
Skins
  • Light
  • Cerulean
  • Cosmo
  • Flatly
  • Journal
  • Litera
  • Lumen
  • Lux
  • Materia
  • Minty
  • Morph
  • Pulse
  • Sandstone
  • Simplex
  • Sketchy
  • Spacelab
  • United
  • Yeti
  • Zephyr
  • Dark
  • Cyborg
  • Darkly
  • Quartz
  • Slate
  • Solar
  • Superhero
  • Vapor

  • Default (No Skin)
  • No Skin
Collapse
Code Project
CODE PROJECT For Those Who Code
  • Home
  • Articles
  • FAQ
Community
D

DavodM

@DavodM
About
Posts
6
Topics
0
Shares
0
Groups
0
Followers
0
Following
0

Posts

Recent Best Controversial

  • How to use MS-Word Equation Editor in ASP.Net
    D DavodM

    http://tinyurl.com/mehqwx[^]

    ASP.NET csharp asp-net tutorial question

  • User Input Into Array, Need To Check Array Member If It Is Greater Then 100 Or Less Then 0
    D DavodM

    You'll get your head round it eventually! Its just a matter of getting used to the way of thinking. I'm assuming this is your first programming language?

    C# css data-structures help lounge

  • User Input Into Array, Need To Check Array Member If It Is Greater Then 100 Or Less Then 0
    D DavodM

    Im guessing you had been round the for loop a couple of times before you put the right input in? I would suggest scrapping the user input code and starting again, sometimes its easier than fixing something. You might want to break it down into smaller chunks, i.e get the input and store as a string, then try parsing it to an int and then if that works add it to the array, if not ask the user again. Repeat the above 3 times and bingo! The code will be more verbose but it will be easier to debug and understand and once you have it working you can always go back over it and refactor it. Terse code can look better but it can also be hard to understand and maintain.

    C# css data-structures help lounge

  • User Input Into Array, Need To Check Array Member If It Is Greater Then 100 Or Less Then 0
    D DavodM

    Looks like an interesting assignment. Are you still having problems with the previous bits?

    C# css data-structures help lounge

  • User Input Into Array, Need To Check Array Member If It Is Greater Then 100 Or Less Then 0
    D DavodM

    I see. It should be a fairly easy fix then. (although you have some other problems in your user input code) The easiest way to fix the crash is to remove the else block completely. Think about it, if intSet[i] is not between 0 and 100 there is not an entry in the boolSet array to hold the information, and in fact you don't need one if you only care about the numbers 0 to 100 anyway! The best way with your current code would be to have all the elements in boolSet set to false to start with then let the code you already have set to true the ones the user entered. For the problems with your input code, try entering 1, 2, d. :cool: Also if you have the requirements from the assignment posting them here (or the relevant parts) would give us a clear idea of what you have to achieve. (note I have no intention of doing your homework for you but im quite happy to you help you with problems as you have been doing the work yourself so far! :laugh: )

    C# css data-structures help lounge

  • User Input Into Array, Need To Check Array Member If It Is Greater Then 100 Or Less Then 0
    D DavodM

    Your crash is likely coming from here:

    else
    {

    boolSet\[intSet\[i\]\] = false; 
    

    }

    If intSet[i] is greater than 100 or less then 0(lets say its 103) we go into the else block. Your boolSet array only has 101 items in it so trying to access boolSet[103] will raise and arrayOutOfBoundsException (or something similar) is that the message you see? Also can you state the programs goals more clearly? What information should boolSet hold?

    C# css data-structures help lounge
  • Login

  • Don't have an account? Register

  • Login or register to search.
  • First post
    Last post
0
  • Categories
  • Recent
  • Tags
  • Popular
  • World
  • Users
  • Groups