7 Replies - 1250 Views - Last Post: 26 March 2012 - 10:37 PM Rate Topic: -----

#1 frostyy  Icon User is offline

  • New D.I.C Head

Reputation: 0
  • View blog
  • Posts: 2
  • Joined: 25-March 12

C# Debugging homework easy application

Posted 25 March 2012 - 05:23 PM

Cant figure out what is wrong with local variable "letter". Needs to show letters A-Z

// Program displays every possible ID number for a company
// ID number is a letter, followed by a two-digit number
// For example -- A00 or Z99
// Go to a new display line after every 20 IDs
using System;
public class DebugSix3
{
    public static void Main()
    {
        char letter;
        int number;
        const int LOW = 0;
        const int HIGH = 99;
        const int NUMINROW = 20;
        for (number = LOW; number <= HIGH; ++number)
        {
            if (number % NUMINROW == 0)
                Console.WriteLine();
            Console.Write("{0}{1} ", letter, number.ToString("D2"));
        }
    }
}



Is This A Good Question/Topic? 0
  • +

Replies To: C# Debugging homework easy application

#2 superkb10  Icon User is offline

  • D.I.C Regular

Reputation: 25
  • View blog
  • Posts: 272
  • Joined: 27-November 11

Re: C# Debugging homework easy application

Posted 25 March 2012 - 06:04 PM

You never assign letter a value.
Was This Post Helpful? 1
  • +
  • -

#3 Tenderfoot  Icon User is offline

  • D.I.C Head
  • member icon

Reputation: 8
  • View blog
  • Posts: 139
  • Joined: 21-March 12

Re: C# Debugging homework easy application

Posted 26 March 2012 - 02:05 AM

If I understood you correctly, you want to display every letter + the number 1-99, from A-Z?

If not, ignore the code below:

[removed code]

This post has been edited by tlhIn`toq: 26 March 2012 - 07:09 AM
Reason for edit:: We don't provide finished code for homework

Was This Post Helpful? 0
  • +
  • -

#4 negligible  Icon User is offline

  • D.I.C Regular

Reputation: 62
  • View blog
  • Posts: 302
  • Joined: 02-December 10

Re: C# Debugging homework easy application

Posted 26 March 2012 - 03:23 AM

Hiya, a bunch of tutorials here you can read and follow on debugging. They're under the "spoiler" cut right at the top. Essential skill to learn!

With a breakpoint in place you can hover the mouse over the "letter" variable and see exactly what value it contains. Which in the case of your code, please go and check, should be null as you have never assigned "letters" to anything.

letter = A; Assigning "letter" to A.

http://www.dreaminco...cle-you-wanted/

TenderFoot not sure about writing out the whole program like that... rookies need to learn to think through and plan out their applications themselves.

This post has been edited by negligible: 26 March 2012 - 03:30 AM

Was This Post Helpful? 0
  • +
  • -

#5 Curtis Rutland  Icon User is online

  • (╯°□°)╯︵ (~ .o.)~
  • member icon


Reputation: 3792
  • View blog
  • Posts: 6,387
  • Joined: 08-June 10

Re: C# Debugging homework easy application

Posted 26 March 2012 - 06:06 AM

@Tenderfoot, don't do people's homework for them. That doesn't help anyone.
Was This Post Helpful? 0
  • +
  • -

#6 Tenderfoot  Icon User is offline

  • D.I.C Head
  • member icon

Reputation: 8
  • View blog
  • Posts: 139
  • Joined: 21-March 12

Re: C# Debugging homework easy application

Posted 26 March 2012 - 10:36 AM

I did try to explain as I went on - but I get your point and it won't happen again.
Was This Post Helpful? 0
  • +
  • -

#7 frostyy  Icon User is offline

  • New D.I.C Head

Reputation: 0
  • View blog
  • Posts: 2
  • Joined: 25-March 12

Re: C# Debugging homework easy application

Posted 26 March 2012 - 06:15 PM

I'm sorry for posting my 'homework', actually i figured almost all of it out already, there was just a small problem for which i needed some help. Thank you to everybody how tried to help me, i got it now though :)
Was This Post Helpful? 0
  • +
  • -

#8 Curtis Rutland  Icon User is online

  • (╯°□°)╯︵ (~ .o.)~
  • member icon


Reputation: 3792
  • View blog
  • Posts: 6,387
  • Joined: 08-June 10

Re: C# Debugging homework easy application

Posted 26 March 2012 - 10:37 PM

For future reference, we don't mind helping with homework. We usually enjoy it. We just don't do the work for people. It's not constructive, because our philosophy isn't to solve problems, but to make better programmers.
Was This Post Helpful? 0
  • +
  • -

Page 1 of 1