Need help editing code so it dispays: double int 0.06 tax on $79.95 is $4.80 dou
ID: 3545113 • Letter: N
Question
Need help editing code so it dispays:
double int
0.06 tax on $79.95 is $4.80
double double
0.06 tax on $79.95 is $.480
using System;
public class TaxCalculation
{
public static void Main()
{
TaxCalculate(79.95, 0.06);
TaxCalculate(79.95, 6);
}
public static void TaxCalculate(double salePrice,
double taxRate){
Console.WriteLine("The tax using doubles is {0}.", (salePrice * taxRate).ToString("C"));
}
public static void TaxCalculate(double salePrice, int percentage){
double taxRate = (double) percentage * .01;
Console.WriteLine("The tax using a double and integer is {0}.", (salePrice * taxRate).ToString("C"));
}
}
Explanation / Answer
Hello, here is the answer for your question. highlighted lines are modifed/added.
using System;
public class TaxCalculation
{
public static void Main()
{
TaxCalculate(79.95, 0.06);
TaxCalculate(79.95, 6);
Console.ReadKey();
}
public static void TaxCalculate(double salePrice, double taxRate){
Console.WriteLine("double double");
Console.WriteLine(taxRate+" tax on $"+salePrice+" is {0}", (salePrice * taxRate).ToString("C"));
}
public static void TaxCalculate(double salePrice, int percentage){
double taxRate = (double) percentage * .01;
Console.WriteLine("double int");
Console.WriteLine(taxRate+ " tax on $" + salePrice + " is {0}", (salePrice * taxRate).ToString("C"));
}
}
Related Questions
drjack9650@gmail.com
Navigate
Integrity-first tutoring: explanations and feedback only — we do not complete graded work. Learn more.