Ask Question
13 April, 21:45

Write a while loop that adjusts userValue while userValue is less than 0 or greater than 80. If userValue is greater than 80, then subtract 5 from userValue. If userValue is less than 0, then add 10 to userValue. 5 from userValue.

+2
Answers (1)
  1. 13 April, 21:54
    0
    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 (userValue80) {

    if (userValue>80) {

    userValue=userValue-5;

    }

    else if (userValue<0) {

    userValue=userValue+10;

    }

    }

    System. out. println ("New UserValue is: "+userValue);

    }

    }

    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
Know the Answer?
Not Sure About the Answer?
Get an answer to your question ✅ “Write a while loop that adjusts userValue while userValue is less than 0 or greater than 80. If userValue is greater than 80, then subtract ...” in 📙 Computers & Technology if there is no answer or all answers are wrong, use a search bar and try to find the answer among similar questions.
Search for Other Answers