Home / Expert Answers / Computer Science / create-an-c-application-named-testclassifiedad-that-instantiates-and-displays-at-least-two-classifi-pa560

(Solved): Create an C# application named TestClassifiedAd that instantiates and displays at least two Classifi ...



Create an C# application named TestClassifiedAd that instantiates and displays at least two ClassifiedAd objects. A ClassifiedAd has fields for a Category (For example, Used Cars and Help Wanted), a number of Words, and a price. Include properties that contain get and set accessors for the category and number of words, but only a get accessor for the price. The price is calculated at nine cents per word. Note: Your output should be formatted as: The classified ad with 100 words in category Used Cars costs $9.00 The classified ad with 60 words in category Help Wanted costs $5.40 In order to prepend the $ to currency values, the program will need to use the CultureInfo.GetCultureInfo method. In order to do this, include the statement using System.Globalization; at the top of your program and format the output statements as follows: WriteLine("This is an example: {0}", value.ToString("C", CultureInfo.GetCultureInfo("en-US"))); Class executes correctly 0 out of 1 checks passed. Review the results below for more details. Checks Unit TestIncomplete ClassifiedAd class test Build Status Build Failed Build Output Compilation failed: 4 error(s), 0 warnings NtTest8c424fdb.cs(15,22): error CS1061: Type `ClassifiedAd' does not contain a definition for `Words' and no extension method `Words' of type `ClassifiedAd' could be found. Are you missing an assembly reference? TestClassifiedAd.cs(21,7): (Location of the symbol related to previous error) NtTest8c424fdb.cs(17,24): error CS1061: Type `ClassifiedAd' does not contain a definition for `Words' and no extension method `Words' of type `ClassifiedAd' could be found. Are you missing an assembly reference? TestClassifiedAd.cs(21,7): (Location of the symbol related to previous error) NtTest8c424fdb.cs(20,44): error CS1061: Type `ClassifiedAd' does not contain a definition for `Words' and no extension method `Words' of type `ClassifiedAd' could be found. Are you missing an assembly reference? TestClassifiedAd.cs(21,7): (Location of the symbol related to previous error) NtTest8c424fdb.cs(22,44): error CS1061: Type `ClassifiedAd' does not contain a definition for `Words' and no extension method `Words' of type `ClassifiedAd' could be found. Are you missing an assembly reference? TestClassifiedAd.cs(21,7): (Location of the symbol related to previous error) Test Contents [TestFixture] public class ClassifiedAdClassTest { [Test] public void ClassifiedAdTest() { ClassifiedAd myClassifiedAd = new ClassifiedAd(); ClassifiedAd yourClassifiedAd = new ClassifiedAd(); myClassifiedAd.Category = "Used cars"; myClassifiedAd.Words = 100; yourClassifiedAd.Category = "Help wanted"; yourClassifiedAd.Words = 60; Assert.AreEqual("Used cars", myClassifiedAd.Category); Assert.AreEqual(100, myClassifiedAd.Words); Assert.AreEqual("Help wanted", yourClassifiedAd.Category); Assert.AreEqual(60, yourClassifiedAd.Words); } } 10.00 out of 10.00 Program output correctly 1 out of 1 checks passed. Great work! Checks Test CaseComplete Output matches desired format Input Output The classified ad with 100 words in category Used Cars costs $9.00 The classified ad with 60 words in category Help Wanted costs $5.40

using System.Globalization;

using static System.Console;

 

public class TestClassifiedAd

{

    public static void Main()

    {

        ClassifiedAd ad1 = new ClassifiedAd();

        ad1.Category = "Used Cars";

        ad1.NumWords = 100;

        

        ClassifiedAd ad2 = new ClassifiedAd();

        ad2.Category = "Help Wanted";

        ad2.NumWords = 60;

        

        WriteLine("The classified ad with {0} words in category {1} costs {2}", ad1.NumWords, ad1.Category, ad1.Price.ToString("C", CultureInfo.GetCultureInfo("en-US")));

        WriteLine("The classified ad with {0} words in category {1} costs {2}", ad2.NumWords, ad2.Category, ad2.Price.ToString("C", CultureInfo.GetCultureInfo("en-US")));

    }

}

 

class ClassifiedAd

{

    public string Category { get; set; }

    public int NumWords { get; set; }

 

    public double Price

    {

        get { return NumWords * 0.09; }

    }

}

Programming Exercise 9-2

Programming Exercise 9-2


We have an Answer from Expert

View Expert Answer

Expert Answer


Answer: CODE: C# PROGRAMMING LANGUAGE using static System.Console; using System.Globalization; public class TestClassifiedAd { public static void Main() { ClassifiedAd ad1 = new
We have an Answer from Expert

Buy This Answer $5

Place Order

We Provide Services Across The Globe