+ 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
3 Réponses
+ 2
thank you ,i tried and it worked
+ 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.
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);
}