+ 1

Get That Discount C#

Task looks easy I think I am missiing something .Can you help me ? MY CODE : using System; using System.Collections.Generic; using System.Linq; using System.Runtime.InteropServices; using System.Text; using System.Threading.Tasks; namespace SoloLearn { class Program { static void Main(string[] args) { double totalPrice = Convert.ToDouble(Console.ReadLine()); //call the method Discount(); } //complete the method declaration static double Discount(double totalPrice) { //complete the method body if (totalPrice>=100000) { return totalPrice*0.8; } else { return totalPrice; } } } } ERROR: usercode/file0.cs(18,13): error CS7036: There is no argument given that corresponds to the required formal parameter 'totalPrice' of 'Program.Discount(double)'

1st Jul 2022, 9:28 AM
Tugba Ceren Turhan
Tugba Ceren Turhan - avatar
2 odpowiedzi
+ 5
Pass variable <totalPrice> as argument for Discount() method to make it work. And print the value returned by Discount() method. // call the method Console.WriteLine( Discount( totalPrice ) );
1st Jul 2022, 9:40 AM
Ipang
+ 1
It worked thanks ! Ipang
1st Jul 2022, 10:02 AM
Tugba Ceren Turhan
Tugba Ceren Turhan - avatar