Answer to Question #329745 in C# for madhu

Question #329745

Write a program to calculate the bonus of the employee given the basic salary of the employee.








The bonus will be calculated based on the below category.








if Basic Salary-15000 and less than 20001 calculate bonus as 17% of basic+1500 if Basic Salary>10000 and less than 15001 calculate bonus as 15% of basic+1200 If Basic Salary<10001 calculate bonus as 12% of basic+1000 for rest calculate bonus as 8% of basic+500








Business rule:









1) If the salary given is a negative number, then print -1








2) if the salary given is more than 1000000, then print -2.








3) All the test cases has the calculated bonus as integer value only.









Create a class named UserProgramCode that has the following static method public static int calculateBonus(int input1) Create a class named Program that accepts the inputs and calls the static method present in the UserProgramCode.

1
Expert's answer
2022-04-17T13:53:57-0400
internal class Program
{
    class UserProgramCode
    {
        public static int calculateBonus(int input)
        {
            if (input < 0)
            {
                return -1;
            }
            if (input > 1000000)
            {
                return -2;
            }
            if (input > 15000 && input < 20001)
            {
                double Bonus = input * 0.17 + 1500;
                return (int)Bonus;
            }
            if (input > 10000 && input < 15001)
            {
                double Bonus = input * 0.15 + 1200;
                return (int)Bonus;
            }
            if (input < 10001)
            {
                double Bonus = input * 0.12 + 1000;
                return (int)Bonus;
            }
            else
            {
                double Bonus = input * 0.08 + 500;
                return (int)Bonus;
            }
        }
    }


    static void Main()
    {
        Console.Write("Enter Salary: ");
        int Bonus = UserProgramCode.calculateBonus(int.Parse(Console.ReadLine()));
        Console.WriteLine($"Bonus: {Bonus}");
        Console.ReadKey();
    }
}

Need a fast expert's response?

Submit order

and get a quick answer at the best price

for any assignment or question with DETAILED EXPLANATIONS!

Comments

No comments. Be the first!

Leave a comment

LATEST TUTORIALS
New on Blog
APPROVED BY CLIENTS