Java | Sololearn: Learn to code for FREE!



Can someone help me code this i’m kinda confused. Call a method named getVelocity that returns an integer and has a Scanner parameter. This method must use a either a while loop or a do-while loop to prompt the user to enter the maximum wind velocity (speed) and return it. A valid value for the maximum wind velocity is between 2 and 50 (inclusive). As long as the value is not valid, display a message saying the value is invalid and prompt the user to enter the value again

4/23/2021 11:08:47 PM

Diana Lopez

4 Answers

New Answer


static int getVelocity(Scanner sc) { System.out.print("Enter maximum wind velocity : "); int v = sc.nextInt(); while(!(v >= 2 && v <= 50)) { System.out.print("\nInvalid input. Enter again : "); v = sc.nextInt(); } return v; }


Welcome to Solo learn!!! You just entered here some hours ago. You can compete this project later also.Please kindly learn little bit then try and stay calm you'll definitely complete this project by your own. If you stuck some where this community will surely help you


I see what i did wrong now thank you so much for the help :) I appreciate it


You're welcome Diana Lopez ^_^