I'm starting out trying to learn code, using visual studio and a c# book. It doesn't go over how to change a double to a dollar amount. The following is the program I have so far (an assignment). How can I either change the format of my output (WITHOUT adding using system.globalization;) Or make it where the output will always read a 1.1 as $1.10 and 1.5678 as $1.57. For example if I were to put that I work 39 hours at 10.50 an hour.
{
//Declare all variables:
double Hours;
double Rate;
double GrossPay;
double FederalTax;
double StateTax;
double SocialSecurity;
double NetPay;
double TotalTax;
//Introduction:
Console.WriteLine("Welcome to the Pay Calculator!!!");
//User input of hours:
Console.WriteLine("Please enter the hours you worked this pay period: ");
Hours = Convert.ToDouble(Console.ReadLine());
//User input for rate:
Console.WriteLine("Please enter your rate of pay: ");
Rate = Convert.ToDouble(Console.ReadLine());
//Calculations
GrossPay = Hours * Rate;
FederalTax = GrossPay * 0.20d;
StateTax = GrossPay * 0.05d;
SocialSecurity = GrossPay * 0.062d;
NetPay = GrossPay - FederalTax - StateTax - SocialSecurity;
TotalTax = FederalTax + StateTax + SocialSecurity;
//OutPut
Console.WriteLine($"Your gross pay is: ${GrossPay}");
Console.WriteLine($"Your federal tax obligation is: ${FederalTax}");
Console.WriteLine($"Your state tax obligation is: ${StateTax}");
Console.WriteLine($"Your social security obligation is: ${SocialSecurity}");
Console.WriteLine($"Your total tax obligation is: $ {TotalTax}");
Console.WriteLine($"This will bring your total net pay to: ${NetPay}");
Console.ReadKey();
}