Write the following code using c #, Write a method that takes two arguments: a cost price and a two letter province code. It will calculate and display the selling price. (If province is Ontario a tax of 13% is added to the price, if the province is Quebec a tax of 17% is added to the cost price. There is no tax for the rest of the provinces and territories). In your main, call this method enough times to fully test it
时间: 2023-07-02 12:15:19 浏览: 87
Sure, here's the C# code for the method you described:
```
public void CalculateSellingPrice(double costPrice, string provinceCode) {
double taxRate = 0.0;
if (provinceCode == "ON") {
taxRate = 0.13;
} else if (provinceCode == "QC") {
taxRate = 0.17;
}
double sellingPrice = costPrice * (1.0 + taxRate);
Console.WriteLine("The selling price is: " + sellingPrice.ToString("C"));
}
```
And here's an example of how you could call this method in your `Main` function to test it:
```
static void Main(string[] args) {
CalculateSellingPrice(100.0, "ON"); // This should output $113.00
CalculateSellingPrice(100.0, "QC"); // This should output $117.00
CalculateSellingPrice(100.0, "AB"); // This should output $100.00
}
```
Hope that helps!
阅读全文