static void Main(string[] args) { const decimal LOW_RATE = 5.65M; const decimal HIGH_RATE = 49.99M; const decimal WEEKLY_RATE = 40M; decimal hourlyRate; decimal payRate; Console.Write("Enter the hourly rate: "); hourlyRate = Convert.ToDecimal(Console.ReadLine()); if (hourlyRate <= LOW_RATE) { Console.WriteLine("Error: {0} is below the min rate of {1}", hourlyRate.ToString("C"), LOW_RATE.ToString("C")); Console.Write("Enter the correct hourly rate: "); hourlyRate = Convert.ToDecimal(Console.ReadLine()); } else if (hourlyRate >= HIGH_RATE) { Console.WriteLine("Error: {0} is above the max rate of {1}", hourlyRate.ToString("C"), HIGH_RATE.ToString("C")); Console.Write("Enter the correct hourly rate: "); hourlyRate = Convert.ToDecimal(Console.ReadLine()); } payRate = hourlyRate * WEEKLY_RATE; Console.WriteLine("Pay Rate: \t {0}", hourlyRate.ToString("C")); Console.WriteLine("Weekly Rate: \t {0}", payRate.ToString("C")); }
static void Main() { const double LOW_RATE = 5.65; const double HIGH_RATE = 49.99; double hourlyRatePay; Console.Write("Enter the hourly rate of pay:"); hourlyRatePay = Convert.ToDouble(Console.ReadLine()); if (hourlyRatePay <= LOW_RATE) { Console.WriteLine("Error: The rate of pay {0} is lower than {1}", hourlyRatePay.ToString("C"), LOW_RATE.ToString("C")); } else if (hourlyRatePay >= HIGH_RATE) { Console.WriteLine("Error: The rate of pay {0} is higher than {1}", hourlyRatePay.ToString("C"), HIGH_RATE.ToString("C")); } else { Console.WriteLine("Rate of pay entered: {0}", hourlyRatePay.ToString("C")); } }
static void Main() { double hourlyRate; const double LOW_RATE = 5.65; Console.Write("Enter the hourly rate of pay: "); hourlyRate = Convert.ToDouble(Console.ReadLine()); if (hourlyRate <= LOW_RATE) { Console.WriteLine("Error: You entered an amount lower than {0}", LOW_RATE.ToString("C")); } else { Console.WriteLine("You entered {0} as the hourly rate.", hourlyRate.ToString("C")); } }