create a program in c#, named bonus calculation that includes two overloaded met
ID: 3586216 • Letter: C
Question
create a program in c#, named bonus calculation that includes two overloaded methods-one that accepts a salary and a bonus expressed as double (for example, 600.00 and 0.10, where 0.10 represents a 10 percent bonus), and one that accepts a salary as a double and a bonus an integer( for example 600.00 and 50, where 50 represents a $50 bonus). Each method displays the salary, the bonus in dollars and the total. Include a Main() method that demonstrates each method
Sample output
Would you like to calculate slary bonuses [y/n]? p
Would you like to calculate slary bonuses [y/n]? o
Would you like to calculate slary bonuses [y/n]? y
Enter the salary:600.78
Enter the increase rate:0.15
Enter the salary bonus amount (integer value): 55
The $600.78 salary with a 15.00% bonus increment is: $690.90
The $600.78 salary plus a $55.00 bonus is: $655.78
Would you like to calculate salary bonuses [y/n]? y
Enter the salary:1000.99
Enter the increase rate:0.25
Enter the salary bonus amount (integer value): 121
The $1,000.99 salary with a 25.00% bonus increment is: $1,251.24
The $1000.99 salary plus a $121.00 bonus is: $1,121.99
Would you like to calculate salary bonuses [y/n]? n
Explanation / Answer
using System;
public class Test
{
//function definitions
public static void salary_incr1(double salary,double bonusRate)
{
double new_salary = salary + salary *bonusRate;
Console.WriteLine(" The $"+salary+" salary with a "+ bonusRate +"% bonus increment is: $"+new_salary);
}
public static void salary_incr2(double salary,int bonus)
{
double new_salary = salary + bonus;
Console.WriteLine(" The $"+salary+" salary plus a $"+bonus +" bonus is: $"+new_salary);
}
public static void Main()
{
double salary,rate;
int bonus;
string option;
Console.WriteLine(" Would you like to calculate salary bonuses [y/n]? ");
option = Console.ReadLine();
if(option == "y")
{
Console.WriteLine(" Enter the salary:");
salary = Convert.ToDouble(Console.ReadLine());
Console.WriteLine(" Enter the increase rate:");
rate = Convert.ToDouble(Console.ReadLine());
Console.WriteLine(" Enter the salary bonus amount (integer value): ");
bonus = Convert.ToInt32(Console.ReadLine());
//function calls
salary_incr1(salary,rate);
salary_incr2(salary,bonus);
}
}
}
Output:
Related Questions
Navigate
Integrity-first tutoring: explanations and feedback only — we do not complete graded work. Learn more.