107 320
Assignments Done
98.9%
Successfully Done
In March 2023

# Answer to Question #253249 in C# for Dani

Question #253249
: Create a class Worker with attributes name, age and salary. This class contain default
constructor, GetData and Display.
a) A function SalariedEmployeeComission calculates the commission of the worker and
display total salary constantly.
b) A function HourlyEmployeeCommission calculates the commission of Worker with of
5% and display total salary constantly
1
2021-10-19T02:05:46-0400
using System;
using System.Collections.Generic;

namespace App
{

class Worker {
//with attributes name, age and salary.
private string name;
private int age;
private double salary;
private double commissionPerc;

public Worker() { }

public void GetData() {
Console.Write("Enter name: ");
Console.Write("Enter age: ");
Console.Write("Enter salary: ");
Console.Write("Enter commission for salaried employee: ");
}
public void Display() {
Console.WriteLine("Name: {0}", name);
Console.WriteLine("Age: {0}", age);
}
/// <summary>
/// A function SalariedEmployeeComission calculates the commission of the worker and display total salary constantly.
/// </summary>
public void SalariedEmployeeComission()
{
double commission = salary * commissionPerc / 100.0;
double totalSalary = commission + salary;
Console.WriteLine("Salaried Employee Commission {0}%: {1}", commissionPerc, commission);
Console.WriteLine("Salaried Employee Total salary: {0}", totalSalary);
}
/// <summary>
/// A function HourlyEmployeeCommission calculates the commission of Worker with of 5% and display total salary constantly
/// </summary>
public void HourlyEmployeeCommission()
{
commissionPerc = 5;
double commission = salary * commissionPerc / 100.0;
double totalSalary = commission + salary;
Console.WriteLine("Hourly Employee Commission {0}%: {1}", commissionPerc, commission);
Console.WriteLine("Hourly Employee Total salary: {0}", totalSalary);
}
}

class Program
{
static void Main(string[] args)
{
Worker Worker = new Worker();
Worker.GetData();
Worker.Display();

Worker.SalariedEmployeeComission();
Console.WriteLine();
Worker.HourlyEmployeeCommission();

}

}
}

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!