Answer:
import java.util.Scanner;
public class num5 {
public static void main(String[] args) {
Scanner in = new Scanner(System.in);
System.out.println("Enter a value");
int userValue = in.nextInt();
//The While Loop
while(userValue<0||userValue>80){
if(userValue>80){
userValue=userValue-5;
}
else if(userValue<0){
userValue=userValue+10;
}
}
System.out.println("New UserValue is: "+userValue);
}
}
Step-by-step explanation:
- This is solved using Java programming language
- Use the scanner class to receive the userValue
- Create a while loop with the condition as given in the question : userValue is less than 0 or greater than 80.
- Within the while loop use if and else if statement to subtract 5 from the userValue if it is greater than 80 or add 10 to userValue if it is less than 0