Ask Question
31 August, 04:46

Write a Bare Bones program that takes as input two variables X and Y. (Again, assume these values are set before your program begins to execute.) Your program should place a 0 in the variable Z if the variable X is less than or equal to Y, and your program should place a 1 in the variable Z if the variable X is greater than Y.

+4
Answers (1)
  1. 31 August, 08:22
    0
    import java. util. Scanner;

    public class num8 {

    public static void main (String[] args) {

    Scanner in = new Scanner (System. in);

    System. out. println ("Enter first number");

    int X = in. nextInt ();

    System. out. println ("Enter second number");

    int Y = in. nextInt ();

    int Z;

    if (X < = Y) {

    Z = 0;

    }

    else if (X > = Y) {

    Z = 1;

    }

    }

    }

    Explanation:

    The program is implemented in Java In order to set the values for X and Y, The Scanner class is used to receive and store the values in the variables (Although the questions says you should assume these values are set) The if conditional statement is used to assign values (either 0 or 1) to variable Z as required by the question.
Know the Answer?
Not Sure About the Answer?
Find an answer to your question ✅ “Write a Bare Bones program that takes as input two variables X and Y. (Again, assume these values are set before your program begins to ...” 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