Lowest price ever! Learn Generative AI for 48% less!
Get my discount0
Java
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 Answers
+ 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;
}
+ 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
+ 1
I see what i did wrong now thank you so much for the help :) I appreciate it
+ 1
You're welcome Diana Lopez ^_^