Why it doesn't work with the bracket | Sololearn: Learn to code for FREE!
New course! Every coder should learn Generative AI!
Try a free lesson
+ 1

Why it doesn't work with the bracket

When I add bracket the code didnt work salary+= salary*(perc/100) actually the result is just the same salary with out changes because of the += and when I removed the perc and replace it with a number it worked. Can anyone tell me why this happen https://code.sololearn.com/cDD4GHJc15u3/?ref=app

4th Mar 2022, 9:51 AM
Mohammad _io_
3 Answers
+ 2
thank you ,i tried and it worked
5th Mar 2022, 9:16 AM
Mohammad _io_
+ 1
C# does not recognize 100 as a possible double. Because it is a integer. This is called integer-division. Make sure that 100 is explicitly made a double.
4th Mar 2022, 11:32 AM
sneeze
sneeze - avatar
0
Because the percentage input is an int Change to: double percent = Convert.ToDouble(Console.ReadLine()); And: static void Increase(double perc,ref double salary) { salary +=salary*(perc/100); }
5th Mar 2022, 11:04 PM
Jackie
Jackie - avatar