Maha

Maha

  • NA
  • 0
  • 324k

Please modified the program

Aug 5 2012 9:32 PM
This is Question 3 of the Exercise (pdf page 6). How could this program be modified? So that if user entered non numeric value program must end.


using System;

namespace CheckLowRate
{
class EnsureValidPayRate
{
static void Main(string[] args)
{
double payRate;

payRate = HourlyPayRate();

while (true)
{
if (49.99 > payRate && payRate > 5.65)
{
Console.WriteLine("{0} Acceptable", payRate.ToString("C"));
}

if (49.99 < payRate || payRate < 5.65)
{
Console.WriteLine("{0} Not Acceptable", payRate.ToString("C"));
}
payRate = HourlyPayRate();
}
Console.WriteLine("Program Ends");
Console.ReadKey();
}
public static double HourlyPayRate()
{
Console.Write("\nHourly Pay Rate is $");
double HpayRate = Convert.ToDouble(Console.ReadLine());
return HpayRate;
}
}
}


Answers (10)