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 8170855
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 6, 20262026-06-06T21:16:21+00:00 2026-06-06T21:16:21+00:00

Using C# for a console program in MicroSoft Visual Studio 2010, I have made

  • 0

Using C# for a console program in MicroSoft Visual Studio 2010, I have made some changes to this with some help from you guys and this console program is running correctly; however I need to implement a constant static field that will display the motto “To Obey the Girl Scout Law” in the output section of the main method. I know it must be something simple so please bear with me. When I include the public static const string Motto = “To Obey the Girl Scout Law” in the bass class, I get an error message – The constant ‘DemoScouts.GirlScout.Motto’ can not be static. The following is the complete code for this project:

public class GirlScout
{

    public static const string Motto = "To Obey the Girl Scout Law";  

    public static string scoutName;
    public static string enterName()
    {
        return scoutName;
    }

    public static int duesOwed;
    public static int enterAmount()
    {
        return duesOwed;
    }

    public static int troopNumber;
    public static int enterNumber()
    {
        return troopNumber;
    }
}

class MainClass : GirlScout
{
    static void Main()
    {
        Console.WriteLine();
        Console.Write("Enter the Girl Scout's name: ");
        GirlScout.scoutName = Console.ReadLine();
        Console.WriteLine();

        Console.Write("Enter their Troop Number: ");
        string n = Console.ReadLine();
        GirlScout.troopNumber = Int32.Parse(n);
        GirlScout.enterNumber();
        Console.WriteLine();

        Console.Write("Enter the amount they Owe in Dues: $");
        string d = Console.ReadLine();
        GirlScout.duesOwed = Int32.Parse(d);
        GirlScout.enterAmount();
        Console.WriteLine();

        // Seperate the input from the output:
        Console.WriteLine();
        Console.WriteLine(GirlScout.Motto);
        Console.WriteLine("-----------------------------------------------");
        Console.WriteLine();

        // Display the new information:
        Console.WriteLine("The name of the Girl Scout is: {0}", GirlScout.scoutName);
        Console.WriteLine("The troop Number of the Girl Scout is:   {0}", GirlScout.troopNumber);
        Console.WriteLine("The amount of Dues Owed by this Girl Scout is: {0}", GirlScout.duesOwed);

        // Keep the console window open in debug mode.
        Console.ReadKey();
    }
}

}

Any and all advice would be greatly appreciated.

  • 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-06-06T21:16:24+00:00Added an answer on June 6, 2026 at 9:16 pm

    Well, you never initialized the value of scoutName, so what exactly do you expect to print?

    I think you’re missing a line of code like this:

    GirlScout.scoutName = Console.ReadLine();
    

    I have to say, though, that your class is designed very poorly. You have public data members, and your methods seem to have no purpose or meaning – you should brush up on encapsulation, and make your variables private. Use methods to change/get their values.

    If you need any help ask in the comments or in another question.

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

Sidebar

Related Questions

I'm trying to debug tests from visual studio using nunit-console using a VS-macro, but
C# console app with a reference to c:\Program Files (x86)\Microsoft Visual Studio 10.0\Common7\IDE\PrivateAssemblies\DataCollectors\x86\Microsoft.VisualStudio.Coverage.Monitor.dll :
I've written a program in C++. It's just using the console to have it
Consider the following code (written with Visual Studio 2010 and .NET 4.0) using System;
I have this simple program using powershell. This is just a proof of concept,
When I try to compile my c++ project using Visual Studio 2010 in either
I made a console game using Visual C# 2008 Express, the entire game only
The following code (packaged in a 'Console Application' Visual Studio project): using System; using
I am running a console application in MS Visual Studio 2010 in Windows 7
How can I execute a test case from Command Console using NUnit? I had

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.