hello.

i was wondering if same one can help me with 2 thinks and if you se samthing wrong white the code you can say that 2 so i can fix it.

this is my code.

using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;

namespace Uppgift_1
{
    class Product
    {
        private string Produuct;
        private double Price;
        private bool Food;
        private int count;

        private const double foodVATRate = 0.12, otherVATRate = 0.25;
        private decimal finalprice;

        public void Readinput()
    {

    Console.Write("What is the product you want:  ");
    Produuct = Console.ReadLine();
    
    Console.Write("Unit price:  ");
    Price = Console.ReadLine();
    
    Console.Write("Food item y/n:  ");
    Food = Console.ReadLine();

    Console.Write("Count:  ");
    count = Console.ReadLine();


        private void calculateValues()
        {
        
            finalprice = Price * count;

    }
    }
}

and i'm wondering what do i need to do so i can but this in a printresults, dont need the code for it i only want to know where i can put it. i mean in a private void or in a public and where do i write it

and where i'm i going to put the if and else code, dont need that code for it

Sorry for the bad english

Recommended Answers

All 3 Replies

Take the calculateValues method OUT of the Readinput method.
You have them nested together and that will give you an error.

Also:
1) Change your "finalprice" to a double.
2) Add a constructor

Take the calculateValues method OUT of the Readinput method.
You have them nested together and that will give you an error.

Also:
1) Change your "finalprice" to a double.
2) Add a constructor

What's wrong with using a decimal here? They are much more accurate within a reasonable financial range (29 significant figuires vs a double with 15), and are therefore well suited to money related problems where neither extremely large nor extremely small numbers are needed (which is what a double is useful for).

There is nothing "wrong" with it other than a compiler warning of incompatible types.
...it can be fixed easily two ways, but the concentration was on something else.

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.