954,518 Members — Technology Publication meets Social Media
Username:
Password:
Lost login information?
Have something to say? Contribute New Article Reply to this Article

Error

Hello

class Product
	    {
	        private string Produuct;
	        private decimal Price;
	        private decimal Vat;
	        private bool Food;
	        private int Count;
	 
	        private const decimal foodVATRate = 0.12m, otherVATRate = 0.25m;
	        private decimal Finalprice;
	        private decimal Rate;
	 
	        public void Start()
            {
                Readinput();
                CalculateValues();
                Printrecept();
          
	    }

private void Printrecept()
{
 	throw new System.NotImplementedException();
}

private void CalculateValues()
{
 	throw new System.NotImplementedException();
}
	        private void Readinput();
	    }
	            Console.Write("\n\nWhat is the product you want:  ");
	            Produuct = Console.ReadLine();
	 
	            Console.Write("Unit price:  ");
	            decimal.TryParse(Console.ReadLine(), out Price);
	 
	            Console.Write("Food item y/n:  ");
	            char answer = char.Parse(Console.ReadLine());
	            if ((answer == 'y') || (answer == 'Y'))
	            {
	                Food = true;
                Vat = foodVATRate;
	            }
	            else
	            {
                Food = false;
	                Vat = otherVATRate;
	            }
	 
	            Console.Write("Count:  ");
	            int.TryParse(Console.ReadLine(), out Count);

	 
	            private void CalculateValues();
	{
	            Finalprice = Price * Count;
	            Rate = Finalprice * Vat;

	}
	        private void Printrecept();
	{
	            Console.Write("\n++++++++++++++++++++++++++++++++++++++++++++++++++++++");
	            Console.Write("\n\nThe product you want is: " + Produuct);
	            Console.Write("\nThe price: " + Price);
	            Console.Write("\nFood item: " + Food);
	            Console.Write("\nCount: " + Count);
	            Console.Write("\n\nTotal price: " + Finalprice);
	            Console.Write("\nVAT at " + Rate);
	            Console.Write("\n\n++++++++++++++++++++++++++++++++++++++++++++++++++++++");

}


i get 3 errors and i dont know what to do.

A namespace cannot directly contain members such as fields or methods.
this error is for Console.Write("\n\nWhat is the product you want: "); only for consol.

Expected class, delegate, enum, interface, or struct
This error is for void in private void Printrecept();

Expected class, delegate, enum, interface, or struct
this error is for void in private void CalculateValues();

Johan__
Newbie Poster
17 posts since Jan 2012
Reputation Points: 10
Solved Threads: 0
 

Where is the rest of your program -- the stuff that comes before the word "class"?

thines01
Postaholic
Team Colleague
2,424 posts since Oct 2009
Reputation Points: 445
Solved Threads: 402
 

You have a closing bracket on line 31 that should be an opening bracket { .
Also, you will need a closing bracket on line 53 and 71.

skatamatic
Posting Shark
959 posts since Nov 2007
Reputation Points: 403
Solved Threads: 129
 

You have semi-colons where they don't belong, multiple function definitions and a lot of other issues.
Here is the code for class Product slightly reformatted.
There are a lot of things that need to be changed, however.

class Product
   {
      private string Produuct { get; set; }
      private decimal Price { get; set; }
      private decimal Vat { get; set; }
      private bool Food { get; set; }
      private int Count { get; set; }

      private const decimal foodVATRate = 0.12m;
      private const decimal otherVATRate = 0.25m;
      private decimal Finalprice { get; set; }
      private decimal Rate { get; set; }

      public void Start()
      {
         Readinput();
         CalculateValues();
         Printrecept();
      }

      private void Printrecept()
      {
         Console.Write("\n++++++++++++++++++++++++++++++++++++++++++++++++++++++");
         Console.Write("\n\nThe product you want is: " + Produuct);
         Console.Write("\nThe price: " + Price);
         Console.Write("\nFood item: " + Food);
         Console.Write("\nCount: " + Count);
         Console.Write("\n\nTotal price: " + Finalprice);
         Console.Write("\nVAT at " + Rate);
         Console.Write("\n\n++++++++++++++++++++++++++++++++++++++++++++++++++++++");
      }

      private void CalculateValues()
      {
         Finalprice = Price * Count;
         Rate = Finalprice * Vat;
      }

      private void Readinput()
      {
         Console.Write("\n\nWhat is the product you want:  ");
         Produuct = Console.ReadLine();

         Console.Write("Unit price:  ");
         decimal dTemp = 0;
         decimal.TryParse(Console.ReadLine(), out dTemp);
         Price = dTemp;

         Console.Write("Food item y/n:  ");
         char answer = char.Parse(Console.ReadLine());
         if ((answer == 'y') || (answer == 'Y'))
         {
            Food = true;
            Vat = foodVATRate;
         }
         else
         {
            Food = false;
            Vat = otherVATRate;
         }

         Console.Write("Count:  ");
         int iTemp = 0;
         int.TryParse(Console.ReadLine(), out iTemp);
         Count = iTemp;
      }
   }
thines01
Postaholic
Team Colleague
2,424 posts since Oct 2009
Reputation Points: 445
Solved Threads: 402
 

class Product
{

private string Produuct;
private decimal Price;
private decimal Vat;
private bool Food;
private int Count;

private const decimal foodVATRate = 0.12m, otherVATRate = 0.25m;
private decimal Finalprice;
private decimal Rate;

//private void Printrecept()
//{
// throw new System.NotImplementedException();
//}

//private void CalculateValues()
//{
// throw new System.NotImplementedException();
//}
private void Readinput()
{

Console.Write("\n\nWhat is the product you want: ");
Produuct = Console.ReadLine();

Console.Write("Unit price: ");
decimal.TryParse(Console.ReadLine(), out Price);

Console.Write("Food item y/n: ");
char answer = char.Parse(Console.ReadLine());
if ((answer == 'y') || (answer == 'Y'))
{
Food = true;
Vat = foodVATRate;
}
else
{
Food = false;
Vat = otherVATRate;
}

Console.Write("Count: ");
int.TryParse(Console.ReadLine(), out Count);
}


private void CalculateValues()
{
Finalprice = Price * Count;
Rate = Finalprice * Vat;

}
private void Printrecept()
{
Console.Write("\n++++++++++++++++++++++++++++++++++++++++++++++++++++++");
Console.Write("\n\nThe product you want is: " + Produuct);
Console.Write("\nThe price: " + Price);
Console.Write("\nFood item: " + Food);
Console.Write("\nCount: " + Count);
Console.Write("\n\nTotal price: " + Finalprice);
Console.Write("\nVAT at " + Rate);
Console.Write("\n\n++++++++++++++++++++++++++++++++++++++++++++++++++++++");

}
static void Main(string[] args)
{
Product P = new Product();
P.Readinput();
P.CalculateValues();
P.Printrecept();
Console.ReadLine();
}

}


HERE IS THE CORRECTED CODE

ReshmaRajan
Newbie Poster
3 posts since Jan 2012
Reputation Points: 10
Solved Threads: 1
 

This question has already been solved

Post: Markdown Syntax: Formatting Help
You
View similar articles that have also been tagged: