Which of the following scenarios should use a while loop?

(1 point)
• telling the user what format their phone number should be entered in
• displaying an error message if the user enters their phone number in the wrong format
• asking the user to enter a phone number until it's in the right format
• giving the user one try to enter their phone number in the right format

1 answer

The scenario that should use a while loop is:

asking the user to enter a phone number until it's in the right format

A while loop is ideal for situations where you want to continue repeating a task (in this case, asking for input) until a certain condition is met (the phone number is in the right format).