Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

C SHARP Create a class called Employee that includes three pieces of information as private instance variables first name (type string), last name (type string)

C SHARP

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 will calculate 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 commandline 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.

Step by Step Solution

There are 3 Steps involved in it

Step: 1

blur-text-image

Get Instant Access to Expert-Tailored Solutions

See step-by-step solutions with expert insights and AI powered tools for academic success

Step: 2

blur-text-image

Step: 3

blur-text-image

Ace Your Homework with AI

Get the answers you need in no time with our AI-driven, step-by-step assistance

Get Started

Recommended Textbook for

Machine Learning And Knowledge Discovery In Databases European Conference Ecml Pkdd 2018 Dublin Ireland September 10 14 2018 Proceedings Part 1 Lnai 11051

Authors: Michele Berlingerio ,Francesco Bonchi ,Thomas Gartner ,Neil Hurley ,Georgiana Ifrim

1st Edition

3030109240, 978-3030109240

More Books

Students also viewed these Databases questions

Question

Describe Balor method and give the chemical reaction.

Answered: 1 week ago

Question

How to prepare washing soda from common salt?

Answered: 1 week ago