Prime b

Prime b

  • NA
  • 810
  • 345.3k

Help with loop

Jan 3 2012 1:59 PM
This is the problem
Write a console-based application that prompts a user for an
hourly pay rate. While the user enters values less than $5.65
or greater than $49.99, continue to prompt the user. Before
the program ends, display the valid pay rate

My question : Why do i keep getting infinite loop? How can i just make it show the hourly pay rate user entered?

Thats what I have done so far

            double minPayRate = 5.65;
            double maxPayRate = 49.99;
            string inputString;
            double userInput;

            Console.WriteLine("Please enter your hourly pay rate");
            inputString = Console.ReadLine();
            userInput = Convert.ToDouble(inputString);
            while (userInput != minPayRate && userInput != maxPayRate)
            {
                Console.WriteLine("{0}", userInput);
               
            }
            Console.WriteLine("Wrong hourly pay rate sorry");

Answers (2)