Hourly Pay Rate Program 2 Write a program that prompts a user for an hourly pay
ID: 3647555 • Letter: H
Question
Hourly Pay Rate Program 2Write 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 $7.50 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 pay rate as well as the weekly rate, which is calculated as forty times the hourly rate.
Save the program as SecondChancePayRate.es.
Explanation / Answer
solution: namespace ConsoleApplication1 { class Program { static void Main(string[] args) { string stringRate; double payRate; const double MAX = 49.99; const double MIN = 7.5; Console.WriteLine("Enter an hourly pay rate between {0} and {1}.", MIN, MAX); stringRate = Console.ReadLine(); payRate = Convert.ToDouble(stringRate); while (payRate MAX) { Console.WriteLine("That rate is either too large or too small. Please enter an hourly pay rate between {0} and {1}.", MIN, MAX); Console.WriteLine("Enter an hourly pay rate between {0} and {1}.", MIN, MAX); stringRate = Console.ReadLine(); payRate = Convert.ToDouble(stringRate); } Console.WriteLine("Thank you!"); } } }Related Questions
Navigate
Integrity-first tutoring: explanations and feedback only — we do not complete graded work. Learn more.