0

Can somebody help me to deal with this ez code?

Here is the question: Management has decided to increase the total salary budget. The program you are given takes the current salary budget and the raise percentage as input. It should output the salary budget before the increase, then calculate and output the budget with the raises included. Fix the program by completing the Increase() method (which should calculate the new salary budget) and calling it, so that the provided outputs work correctly. Sample Input 150000 15 Sample Output Before the increase: 150000 After the increase: 172500 Explanation The first input (150000) represents the initial value of salary budget, the second one is the raise percentage - 15%. So, after the increase, the salary budget should be 1.15*150000 = 172500. WELL, my code is: using System; using System.Collections.Generic; using System.Linq; using System.Text; using System.Threading.Tasks; namespace SoloLearn { class Program { static void Main(string[] args) { int salaryBudget = Convert.ToInt32(Console.ReadLine()); int percent = Convert.ToInt32(Console.ReadLine()); Console.WriteLine("Before the increase: " + salaryBudget); Increase(ref salaryBudget, percent); Console.WriteLine("After the increase: " + salaryBudget); } static void Increase(ref int a, int b) { a = a * (1 + b/100); } } } AND, the answer is wrong. The answer given by system is: a = a * (b + 100)/100 SO, CAN SOMEBODY TELL ME WHAT IS THE DIFFERENCES?THX!!!

30th Jun 2022, 9:12 AM
Xian
Xian - avatar
2 Réponses
0
To simplify the question is: Whats the differences between a = a * (1 + b/100) and a = a * (b + 100)/100? Its same in math right?
30th Jun 2022, 9:16 AM
Xian
Xian - avatar
0
Parentheses are always calculated first
30th Jun 2022, 9:38 AM
Chris Coder
Chris Coder - avatar