From essays to dissertations, we have experts for all of your assignments!

dot
  • 1.provide your instructions
  • 2.choose an expert in your field
  • 3.track the order progress

C# Console Application project

TASK 1:

Create a new C# Console Application project and add a class called Employee. This class should have two
instance variables: a name (of type String) and a salary (of type double). Implement the constructor with
two parameters that will set up the initial values of the instance variables:

public Employee (string employeeName, double currentSalary)
You must implement the following methods:
getName this is an accessor method that should return the name of the employee
getSalary this is an accessor method that should return the salary of the employee in currency format
raiseSalary this method should raise the employees salary by a certain percentage

add a new method Tax(), which calculates how much tax is
deducted from the Employees annual pay, according to the following criteria:

$0 $18,200            0%        Nil
$18,201 $37,000  19%      19c for each $1 over $18,200
$37,001 $90,000  32.5%    $3,572 plus 32.5% of amounts over $37,000
$90,001 $180,000  37%    $20,797 plus 37% of amounts over $90,000
$180,000 and over    45%    $54,096 plus 45% of amounts over $180,000

Use ifelse statements. Make sure that the final program works correctly and meets the specification by testing it with different salaries in the EmployeeProgram class.

TASK 2:

Create a new C# Console Application project and add a class called Car with the following parameters,
which you will set in the constructor:

fuel efficiency which is measured in miles per gallon (mpg);
fuel in the tank (in litres) with an initial value of 0;
total miles driven with an initial value of 0.

Set up a constant to hold the current cost of fuel in dollars per litre. For the purpose of this program, the
cost per litre of petrol is 1.385$.

You must implement the following methods in the Car class:
getFuel this accessor method should return the amount of fuel in the tank
getTotalMiles this accessor method should return the total miles the car has driven
setTotalMiles this mutator method should update the total miles the car has driven
printFuelCost a method that returns the cost of fuel in dollars and cents.
addFuel this method should add fuel to the tank and calculate the cost of the fill
calcCost this method will take the amount of fuel, in litres, and multiply it by the cost of fuel (in
dollars per litre)
convertToLitres this method should accept a parameter for the number of gallons, convert that
value to litres and return the value in litres. This can be done by multiplying the value by 4.546.
drive this method should simulate driving the car for a certain distance in miles. It will accept the
number of miles driven and update the total miles stored for the car.

Then you will need to calculate the fuel used by dividing the distance driven by mpg. This will return the number of gallons used, which you then need to convert into litres. The method should display a message to state the total cost of the journey, in dollars and cents.

For the purposes of this class, you can assume that the drive() method is never called with a distance that consumes more than the available fuel.

Change the default Program main class name to CarProgram. Write appropriate code in the CarProgram class to test all of the methods that you have implemented. Compile, run and check the program for potential errors.

You can leave a response, or trackback from your own site.

Leave a Reply

Powered by WordPress | Designed by: Premium WordPress Themes | Thanks to Themes Gallery, Bromoney and Wordpress Themes