Click here to Skip to main content
15,912,665 members
Please Sign up or sign in to vote.
1.00/5 (2 votes)
See more:
HELP ME GUYS HOW TO GET VALUES FROM THE USER
C#
class Program
    {
        static void Main(string[] args)
        {
            FruitShop f = new FruitShop();
            int result=f.GetTotalCost("apple", 22);
            Console.WriteLine(result);
            Console.ReadLine();

        }
    }

    public class FruitShop
    {
        public int GetTotalCost(string fruitname, int qty)
        {
            if (fruitname == "apple" && qty > 10)
            {
                return qty * 12;
            }
            else if (fruitname == "apple" && qty <= 10)
            {
                return qty * 15;
            }
            else if (fruitname == "orange" && qty > 20)
            {
                return qty * 7;
            }
            else if (fruitname == "orange" && qty > 10 && qty<20)
            {
                return qty * 8;
            }
            else if (fruitname == "orange" && qty <= 10)
            {
                return qty * 9;
            }
            return 0;
        }
    }
}
Posted

1 solution

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900