-2

How can I have the users input come out as currency? Where should I add the string.Format(); in my code?

        double transitInsA = new double();
        transitInsA = insuranceRate/100;

        double transitInsB = new double();
        transitInsB = transitInsA*insuranceValue;

        double calA = new double();
        calA = 3.6/100;
        double calB = new double();
        calB = calA*transitInsB;
        double calC = new double();
        calC = calB + transitInsB;

        Console.WriteLine("Your transit insurance cost is" + calC);
        Console.ReadLine();
marc_s
  • 732,580
  • 175
  • 1,330
  • 1,459
Edwin
  • 25
  • 5
  • The documentation on how to do this is [here](https://msdn.microsoft.com/en-us/library/dwhawy9k(v=vs.110).aspx). Also, this is a possible duplicate of [How to format string to money](http://stackoverflow.com/questions/10615405/how-to-format-string-to-money) – Drew Kennedy Apr 11 '16 at 17:18

1 Answers1

2

You can do it on the WriteLine:

  Console.WriteLine(String.Format("Your transit insurance cost is {0:C}",calC));
  Console.ReadLine();
kemiller2002
  • 113,795
  • 27
  • 197
  • 251