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; } } }
var
This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)