Ask 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 5 from userValue. If userValue is less than 0, then add 10 to userValue. 5 from userValue.

+4
Answers (1)
  1. 17 October, 03:13
    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 & Technology if the answers seem to be not correct or there’s no answer. Try a smart search to find answers to similar questions.
Search for Other Answers