Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 3969868
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 20, 20262026-05-20T04:00:59+00:00 2026-05-20T04:00:59+00:00

Ok what I am trying to do seems fairly simple, yet it’s not working

  • 0

Ok what I am trying to do seems fairly simple, yet it’s not working the way I want it. I know I’m just not getting something. Essentially I am trying to read console input, assign it to a variable. Then I want to check that variable to see if it is a valid number. If it’s not, I want to tell the user it is invalid and start the loop over again until I get a valid number, then exit. Here is my code, can you please help me understand what I am doing wrong?

    const int AVERAGE_IQ = 100;
    int userIQ;
    bool done = false;

    do
    {
        Console.Write("Please enter an IQ Score between 1 and 200: ");
        userIQ = Convert.ToInt32(Console.ReadLine());

        if (userIQ == 0 || userIQ >= 200)
        {
            Console.WriteLine("You have entered an invalid IQ Score, please try again.");
            done = false;
        }
        else if (userIQ >= AVERAGE_IQ)
        {
            Console.WriteLine("{0} is an above average IQ.", userIQ);
            done = true;
            break;
        }
        else if (userIQ <= AVERAGE_IQ)
        {
            Console.WriteLine("{0} is an below average IQ.", userIQ);
            done = true;
            break;
        }
        else if (userIQ == AVERAGE_IQ)
        {
            Console.WriteLine("{0} is anaverage IQ.", userIQ);
            done = true;
            break;
        }

    } while (done =! true);
  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-20T04:01:00+00:00Added an answer on May 20, 2026 at 4:01 am

    =! should be !=

    You’re doing an assignment, setting done to false. Since:

    while (done =! true); is the same as while (done = !true); which is the same as while (done = false);

    On each iteration, you’re assigning done to be false, which itself evaluates to false, which means your loop will never iterate a second time.

    Change the loop expression to either while (done != true); or better yet while (!done);

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I am trying to do something fairly simple but seems like a near impossible
I'm trying to do what seems fairly simple but I'm getting a null reference....
Seems to be a fairly hit issue, but I've not yet been able to
I am trying to handle simple packet inspection with netfilter hooks. Declaration seems fairly
I have what seems to be a fairly simple scenario that I am trying
What I'm trying to do seems very simple, but for some reason it feels
It seems that I'm getting a conflict when trying to make a relationship because
Just trying to confirm an impression: it seems enums in EF5 + Code First
I'm trying to use JOIN but it seems I am only getting half of
I am trying to test the jQuery Address Plugin and it seems to not

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.