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();

Recommended Answers

All 4 Replies

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

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.

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;
      }
   }
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

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.