Question
Using C#..Create a class called Employee that includes three pieces of information as private instance variables first name (type string), last name (type string) and
Using C#..Create a class called Employee that includes three pieces of information as private instance variables first name (type string), last name (type string) and annual salary (decimal). Have the following items in your class: A constructor that initializes the three values. A no argument contractor that uses above constructor to set the salary to the base salary of 50,000 (US $) with empty string for the first name and last name. Provide properties with get and set accessors for all instance variables. If the monthly salary is negative, the set accessor should leave the instance variable unchanged. void method called SalaryIncrease that accepts a decimal as annual increase rate and applies that to the salary instance variable . An increase of more than 20% will throw an exception with a message of Invalid rate increase! static method ConvertToCAD that converts the paycheck from USD to CAD. Assume that all salaries are in US dollars and they need to be converted into Canadian dollars in the paychecks. Use the exchange rate of 1 USD = 1.30 CAD (to be declared as a static class member as follows:) const decimal EXCHANGE = 1.30 The method header is: public decimal ConvertToCAD( decimal amount) void PrintPaycheck method which calculates and prints the employees monthly paycheck as 1/12 of the annual salary in CAD (uses method ConvertTOCAD) Implement method DisplayEmployee which displays all objects information in well-mannered format. This method must invoke an overridden version of the ToString method of the object. Write a test class named EmployeeTest that demonstrates instantiating objects of your class. Use the following code to create three employee objects and test them. The last three lines of the code willcalculate and print their Paychecks for the month of January 2020. Test your application with the following data. Employee e1 = new Employee("David", "Daviodson", 70000M); Employee e2 = new Employee("John","Johnson", 90000M); Employee e3 = new Employee(); e3.firstName = "Ahmad"; e3.Lastname = "Soleimani"; e1.DisplayEmployee(); e2.DisplayEmployee(); e3.DisplayEmployee(); try { e1.SalaryIncrease(0.1M); e2.SalaryIncrease(0.2M); e3.SalaryIncrease(0.25M); } catch (IndexOutOfRangeException e) { Console.WriteLine(e.Message); } e1.DisplayEmployee(); e2.DisplayEmployee(); e3.DisplayEmployee(); e1.PrintPaycheck(); e2.PrintPaycheck(); e3.PrintPaycheck(); Problem 2 (50%). Write a console app that would generate special random numbers using command line arguments as described below: The first two arguments serve as the lower and upper bounds for the list of random numbers to be generated. All remaining arguments (from the third and onward) indicate a list of integer numbers within the above range that to be excluded from the generated random numbers. The lower bound, upper bound as well as the list of excluded numbers will be passed to method GenerateSpecialRandom which will generate 50 valid random numbers and return them to the Main method using an out array parameter. Main method will take the random numbers and output them separated with commas (,) on the console. Hint: method GenerateSpecialRandom would need to have a variable number of arguments. (i.e., by using params int[] validNumbers ) Sample Run: // a list of random numbers between 5 to 15 but excluding 7,11,9, and 5 myApp.exe 5 15 7 11 9 5 Final generated random numbers are: 14, 12, 6, 10, 14, 8, 13, 10, 8, //No 5,7,9 or 11 are among them!
Step by Step Solution
There are 3 Steps involved in it
Step: 1
Get Instant Access to Expert-Tailored Solutions
See step-by-step solutions with expert insights and AI powered tools for academic success
Step: 2
Step: 3
Ace Your Homework with AI
Get the answers you need in no time with our AI-driven, step-by-step assistance
Get Started