Java | Sololearn: Learn to code for FREE!
¡Nuevo curso! ¡Todo programador debería aprender IA Generativa!
Prueba una lección gratuita


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

23rd Apr 2021, 11:08 PM
Diana Lopez
4 Respuestas
+ 3
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; }
24th Apr 2021, 2:30 AM
Soumik - avatar
+ 6
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
24th Apr 2021, 1:07 AM
Aysha - avatar
+ 1
I see what i did wrong now thank you so much for the help :) I appreciate it
24th Apr 2021, 5:07 AM
Diana Lopez
+ 1
You're welcome Diana Lopez ^_^
24th Apr 2021, 7:44 AM
Soumik - avatar