Ask Question
4 September, 20:37

Write a program using integers userNum and x as input, and output userNum divided by x four times. Ex: If the input is 2000 2, the output is: 1000 500 250 125 Note: In Coral, integer division discards fractions. Ex: 6 / 4 is 1 (the 0.5 is discarded).

+1
Answers (1)
  1. 4 September, 22:13
    0
    import java. util. Scanner;

    public class Division {

    public static void main (String[] args) {

    Scanner in = new Scanner (System. in);

    System. out. println ("Enter an integer");

    int userNum = in. nextInt ();

    System. out. println ("Enter the divisor");

    int x = in. nextInt ();

    int first = userNum/x;

    int second = first/x;

    int third = second/x;

    int fourth = third/x;

    System. out. println (first+" "+second+" "+third+" "+fourth);

    }

    }

    Explanation:

    In Java programming langauge use the scanner class to receive the values from the user (userNum and x) Carryout integer division of userNum/x to obtain the first number Repeat the sam step to obtain the second, third and fourth number Output the numbers to the user
Know the Answer?
Not Sure About the Answer?
Find an answer to your question ✅ “Write a program using integers userNum and x as input, and output userNum divided by x four times. Ex: If the input is 2000 2, the output ...” 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