I took a test last night and I had a program due at the end. I could not figure out. I would like to understand what I did wrong and what I need to remember for future reference. Here is what I had and the instructions.
Using the Visual Studio .NET IDE, write the following program as described. When completed, submit the program using the midterm program assignment on Blackboard.

The user should be prompted for the range of numbers to display.
The user should be prompted to determine if even or odd numbers should be displayed.
The program should display the range of numbers in both decimal and hexadecimal form (inclusive/non-inclusive, it is up to you).
There should be a header line with Decimal and Hex displayed as in the above screenshot.
After the numbers have been displayed, the user should be prompted, asking if they want to run the program again.

using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;

namespace midterm_365
{
    class Program
    {
        static void Main(string[] args)
        {


            //show the questions where to start end and if they want even of odd numbers
            Console.Write("Where do you want to start counting <integer> 0>:");
            Console.ReadLine();
            Console.Write("Where do you want to end counting <integer> 0>:");
            Console.ReadLine();
            Console.Write("Display even or odd numbers <e, o>:");
            Console.ReadLine();

            string hex = string.Empty;

            //gives the location of decimal and hex
            Console.WriteLine("{0} {1,20}", "Decimal", "Hex");

            //ask the customer do they want to run the program again
            Console.Write("Run again <yes/no>:");
            Console.ReadLine();
        }
    }
}

Well gee. You could start by actually paying attention to the user's input.

Ever heard of oblivion? The twilight zone?
What would you think will happen if a user types y or n (or whatever) to

//ask the customer do they want to run the program again
Console.Write("Run again <yes/no>:");
Console.ReadLine();

Try it out, come back and tell me your findings.

ok maybe I didnt make myself clear , I am new at this and I was having a hard time I dont need the third degree from you guys. Oh and the teacher is no help. Thanks for the help.

Im sure if you took this to your teacher they would be more resonable than perhaps you made out.

If you read the notes at the top of the forum, we dont do your home work for you.

Rashakil and ddanbe both have highlighted exactly where your code goes wrong - perhaps if you debugged it and followed along with the data you collect it will be more obvious to you

honeybits,

Let me apologize for my colleague’s answers. Often times it is easy to forget that this forum has many students and new-bees. Do not let them discourage you from asking questions here.

static void Main(string[] args)
        {
            string _countStart;
            string _countEnd;
            string _oddEven;
            int _iStart;
            int _iEnd;

            string _runAgain = "y";

            while (_runAgain.ToLower().StartsWith("y"))
            {
                Console.Write("Where do you want to start counting <integer> 0>:");
                _countStart = Console.ReadLine();
                Console.Write("Where do you want to end counting <integer> 0>:");
                _countEnd = Console.ReadLine();
                Console.Write("Display even or odd numbers <e, o>:");
                _oddEven = Console.ReadLine().Substring(0,1).ToLower();

                if (
                    Int32.TryParse(_countStart, out _iStart)
                    && Int32.TryParse(_countEnd, out _iEnd)
                    && "e,o".Contains(_oddEven)
                    )
                {
                    
                    //gives the location of decimal and hex
                    Console.WriteLine("{0} {1,20}", "Decimal", "Hex");
                    for (int i = _iStart; i < _iEnd; i++)
                    {
                        if (_oddEven == "e")
                            if (i % 2 == 0)
                                Console.WriteLine("{0} {1,23}"
                                    , i.ToString().PadLeft(3,'0')
                                    , i.ToString("x").ToUpper().PadLeft(2,'0'));
                        else
                            Console.WriteLine("{0} {1,23}"
                                , i.ToString().PadLeft(3, '0')
                                , i.ToString("x").ToUpper().PadLeft(2, '0'));
                    }
                }
                else
                {
                    Console.WriteLine("Invalid Entry detected");
                }

                //ask the customer do they want to run the program again
                Console.Write("Run again <yes/no>:");
                _runAgain = Console.ReadLine();
            }

        }

Copy this code and then study it.
What they were trying to say is that you need to get the answer from the ReadLine into a variable. Next you need to actually use the values provided by the user, however you must validate their entries.
Then it is just a matter of looping through the numbers and produce the output.

Now, this is your homework, so you need to go through it line by line, and google anything you are not 100% clear on or ask for clarification on anything. I am a professional programmer, so I only visit here on occation, but others should be able to "Politely!!!" answer your questions.

// Jerry

Dont appologise for me, I didnt say anything offensive, except now having handed the person an answer theres a much greater chance you just made sure they dont learn and understand

Liz,

honeybits already failed the assignment. Asking for information on what went wrong is an appropriate reaction from someone that is interested in learning.

The prior answers in this thread make sense to someone that already has a basic grasp of programming in C#. But it is obvious to me based on the extreme simplicity of the assignment that honeybits is just now getting started.

Hopefully honeybits will actually study it. If not, S/he is doomed (and deservingly so) to fail the entire course.

I have noticed a trend of late by some of us here being over critical and short fused with the newbees. They took the time to ask the question, lets try to give an appropriate response geared towards the level of the student asking the question. I would join any chastising of someone just wanting us to do their homework for them. But asking what they did wrong afterwards… that (IMO) is deserving of an answer.

// Jerry

commented: nice :) +2

honeybits already failed the assignment. Asking for information on what went wrong is an appropriate reaction from someone that is interested in learning.

You should be a bit more paranoid. People come up with all sorts of stories to explain how their assignment isn't a homework assignment, in hopes of getting better help, or just in getting the answer. There's no way to tell whether that's the case here or not.

Jerry,

You got a point there. But...
I'm not a professional like you, (let's say I'm an autodidact) In my answers I try to be as polite as possible. But here I gave honeybits a hint on how to start working on his/her problem, perhaps a bit pedantic? So be it.
honeybits could have tried something and posted a new question, that would have shown his/her effort. I would have responded accordingly and would have given him/her more info.

We tend to be short fused with the new people because they dont bother to read the announcements at the top of the forum, they kinda post "My stuff dont work, fix it" .. sure some of the "my teacher doesnt help" stories will be true, but the problem is for all the times we do something for someone there are probably less than 1 in 100 who will actually work out why you wrote what you wrote, the rest will go "next" and do something else.

All humans are inherantly lazy.

Well I don't know about you, but I was just being short-fused. And i don't really care.

hi there im ulricht

the problem if you still need help is that you are not assigning what the user inputs to any variables.

eg:
Console.Write("Where do you want to start counting <integer> 0>:");
Console.ReadLine();
-------------
should be;
Console.Write("Where do you want to start counting <integer> 0>:");
int Count = Convert.ToInt32(Console.ReadLine());
-----------

the above will work :) have fun

hi there im ulricht

the problem if you still need help is that you are not assigning what the user inputs to any variables.

eg:
Console.Write("Where do you want to start counting <integer> 0>:");
Console.ReadLine();
-------------
should be;
Console.Write("Where do you want to start counting <integer> 0>:");
int Count = Convert.ToInt32(Console.ReadLine());
-----------

the above will work have fun

I just started learning this off the internet a few days ago and even I can tell the problem with his code. LOL

But I do agree you guys could have been a bit less harsh on him.
Maybe its not what your saying but how your saying it ;)

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.