0
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 ответов
+ 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;
}
+ 1
I see what i did wrong now thank you so much for the help :) I appreciate it
+ 1
You're welcome Diana Lopez ^_^