I need to create a console application as shown in the image below.Console Application
The problem is ,that when I enter the hourly rate with the $, a System.FormatException error occurs. It also says Input string was not in correct format.
Here is the snippet of code that causes the problem
double rate = 0;
Console.Write("Enter the hourly rate: ");
rate = double.Parse(Console.ReadLine());
And here is the whole program
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
namespace ICA2_Mason_Clarke
{
class Program
{
static void Main(string[] args)
{
int hoursWorked = 0;
Console.Write("Enter the hours worked: ");
hoursWorked = int.Parse(Console.ReadLine());
double rate = 0;
Console.Write("Enter the hourly rate: ");
rate = double.Parse(Console.ReadLine());
int taxRate = 0;
Console.Write("Enter the tax rate as a percent: ");
taxRate = int.Parse(Console.ReadLine());
double grossPay = rate * hoursWorked;
Console.Write("Gross pay : $");
Console.WriteLine(grossPay);
double taxesDue = grossPay * taxRate / 100;
Console.Write("Taxes due : $");
Console.WriteLine(taxesDue);
double netPay = grossPay - taxesDue;
Console.Write("Net pay : $");
Console.WriteLine(netPay);
Console.Write("Press any key to continue");
Console.Read();
}
}
}