Please tell me what is wrong with this code? | Sololearn: Learn to code for FREE!
New course! Every coder should learn Generative AI!
Try a free lesson
+ 1

Please tell me what is wrong with this code?

Console.WriteLine("Введите число: "); int totalPrice = Convert.ToInt32(Console.ReadLine()); { Console.Write(Discount(totalPrice)); } int i = Convert.ToInt32(Console.ReadLine()); int Discount(int i) { if(i>=10000) i= i*8/10; return i; } Console.Write( i);

1st Dec 2022, 1:35 PM
Петр Вавилов
Петр Вавилов - avatar
5 Answers
+ 2
Save full code and share link here.. Along with task description..
1st Dec 2022, 1:52 PM
Jayakrishna 🇮🇳
+ 1
В магазине проходит акция: если общая стоимость покупки равна или превышает 10000, цена будет снижена на 20%. Программа, которую вам дали, принимает общую стоимость покупки в качестве входных данных. Завершите данный метод, чтобы принять общую стоимость покупки в качестве аргумента, а также рассчитать и вернуть цену со скидкой, если требование кампании выполнено. Метод должен возвращать ту же цену, если скидка не предоставляется. Пример ввода 13000 Пример вывода 10400
1st Dec 2022, 7:49 PM
Петр Вавилов
Петр Вавилов - avatar
+ 1
Method Parameters A store is running a promotion: if the total purchase price is equal to or exceeds 10000, the price will be discounted by 20%. The program you are given takes the total purchase price as input. Complete the given method to take the total purchase price as an argument, and calculate and return the discounted price if campaign's requirement is satisfied. The method should return the same price if discount is not given. Sample Input 13000 Sample Output 10400 Explanation 13000>10000, so the discount should be given: 13000-(0.2*13000) = 10400.
1st Dec 2022, 7:57 PM
Петр Вавилов
Петр Вавилов - avatar
+ 1
static void Main(string[] a) { int i = Convert.ToInt32(Console.ReadLine()); if(i>=10000) i= i*8/10; // or i -= (i*0.2) Console.Write(i); } // no extra output, just i.
1st Dec 2022, 8:10 PM
Jayakrishna 🇮🇳
+ 1
Jayakrishna, Thanks a lot, I solved the problem.
1st Dec 2022, 8:19 PM
Петр Вавилов
Петр Вавилов - avatar