Write a program that prompts a user for an hourly pay rate. The program should j
ID: 3660616 • Letter: W
Question
Write a program that prompts a user for an hourly pay rate. The program should justify the following conditions: If the user enters values less than $5.65 or greater than $49.99, prompt the user to enter the value again. If the user enters an invalid value in the second attempt, display an appropriate error message. If the user enters a valid value on either the first or second attempt, display the valid pay rate. Save the program as EnsureValidPayRate.es.Explanation / Answer
//this one gives infinite tries namespace ConsoleApplication1 { class EnsureValidPayRate { static void Main(string[] args) { double payrate; do { Console.Write("Enter an hourly pay rate between $5.65 and $49.99: $"); payrate = double.Parse(Console.ReadLine()); if (payrate < 5.65 || payrate > 49.99) { Console.WriteLine("The rate entered was out of range."); } } while (payrate < 5.65 || payrate > 49.99); Console.WriteLine("The valid pay rate entered was {0:C}", payrate); Console.ReadLine(); Console.ReadLine(); //stall compiler from closing for 2 line reads }//end main } }Related Questions
Hire Me For All Your Tutoring Needs
Integrity-first tutoring: clear explanations, guidance, and feedback.
Drop an Email at
drjack9650@gmail.com
drjack9650@gmail.com
Navigate
Integrity-first tutoring: explanations and feedback only — we do not complete graded work. Learn more.