Ask Question
25 June, 15:04

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. 25 June, 18: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?
Find 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 and Technology if you're in doubt about the correctness of the answers or there's no answer, then try to use the smart search and find answers to the similar questions.
Search for Other Answers