10
Answers

Please modified the program

Ask a question
Maha

Maha

12y
1.6k
1
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)