Hi, I have the following code but when it is tested it gives me a bunch (lots) o
ID: 3647915 • Letter: H
Question
Hi,I have the following code but when it is tested it gives me a bunch (lots) of errors which there is probably a simple explanation...it worked before. Any ideas?
Create a class named GirlScout that containsfields for a GirlScout's name, troopnumber, and dues owed. Include a constant static field that containsthe last words of the GirlScout motto ("to obeythe Girl Scout law"). Include overloaded constructors thatallow you to set all three nonstatic GirlScout fields to defaultvalues or to parameter values. Also include properties foreach field. Create a class named DemoScouts that instantiatestwo GirlScoutobjects and displays their values. Create one object to usethe default constructor and the other to use the constructor thatrequires arguments. Also display the GirlScout motto.
Coded to:
using System;
using System.Collections.Generic;
using System.Text;
namespace
{
class DemoScout
{
static void Main()
{
GirlScout objScout1 = new GirlScout();
objScout1.Name = "YYYYY";
objScout1.TroopNumber = "1211";
objScout1.DuesOwed = 2111.12;
GirlScout objScout2 = new GirlScout("XXX", "232", 123.23);
//Displaying Scout 1
Console.WriteLine("Scout 1");
Console.WriteLine("Name : " + objScout1.Name);
Console.WriteLine("Troop Number : " +objScout1.TroopNumber);
Console.WriteLine("Dues Owed : " +objScout1.DuesOwed);
Console.WriteLine("Motto : " + GirlScout.motto);
Console.WriteLine(" ");
//Displaying Scout 2
Console.WriteLine("Scout 2");
Console.WriteLine("Name : " + objScout2.Name);
Console.WriteLine("Troop Number : " +objScout2.TroopNumber);
Console.WriteLine("Dues Owed : " +objScout2.DuesOwed);
Console.WriteLine("Motto : " + GirlScout.motto);
Console.Read();
}
}
class GirlScout
{
private string name;
private stringtroopNumber;
private doubleduesOwed;
public static stringmotto = "to obey the Girl Scout law";
public GirlScout()
{
name = string.Empty;
troopNumber = string.Empty;
duesOwed = 0.0;
}
public GirlScout(stringstrName, string strNumber, double dues)
{
name = strName;
troopNumber = strNumber;
duesOwed = dues;
}
public string Name
{
get
{
return name;
}
set
{
name = value;
}
}
public stringTroopNumber
{
get
{
return troopNumber;
}
set
{
troopNumber = value;
}
}
public doubleDuesOwed
{
get
{
return duesOwed;
}
set
{
duesOwed = value;
}
}
}
}
Explanation / Answer
its working fine here.pleases post error log
Related Questions
Hire Me For All Your Tutoring Needs
Integrity-first tutoring: clear explanations, guidance, and feedback.
Drop an Email at
drjack9650@gmail.com
drjack9650@gmail.com
Navigate
Integrity-first tutoring: explanations and feedback only — we do not complete graded work. Learn more.