1answer.
Ask question
Login Signup
Ask question
All categories
  • English
  • Mathematics
  • Social Studies
  • Business
  • History
  • Health
  • Geography
  • Biology
  • Physics
  • Chemistry
  • Computers and Technology
  • Arts
  • World Languages
  • Spanish
  • French
  • German
  • Advanced Placement (AP)
  • SAT
  • Medicine
  • Law
  • Engineering
sesenic [268]
2 years ago
10

Write a Bare Bones program that takes as input two variables X and Y. (Again, assume these values are set before your program be

gins 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.
Computers and Technology
2 answers:
Sauron [17]2 years ago
5 0

Answer:

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.
ratelena [41]2 years ago
3 0

Answer:

#The program sets Z to 0 if the X <= Y. otherwise sets Z to 1 , if the X > Y.

clear Z; # sets Z to 0

clear U; # sets U to 0

clear V; # sets v to 0

clear T; # sets T to 0

while Y not 0 # repeat until Y times

# process to decrement Y by 1

while Y not 0

incr U;

decr Y;

decr U;

while U not 0

incr Y;

decr U;

#process to decrement X by 1

while X not 0

incr V

decr X;

while V not 0

decr V;

while V not 0

incr T;

decr V;

while T not 0

incr X

decr T

#end of main while loop

#after running the main while loop, X will be positive and non - zero number, # #if X > Y. otherwise X and Y will be zero.

#process to increment Z by 1, if X is positive and non - zero number

while X not 0

while X not 0

decr X;

incr Z;

#end of while

Explanation:

The program is totakes in as input two variables X and Y.

The main function of the program is to return or place a 0 in the variable Z if the variable X is less than or equal to Y, and place a 1 in the variable Z if the variable X is greater than Y.

When these conditions are met, end program.

You might be interested in
Write a class Bug that models a bug moving along a horizontal line. The bug moves either to the right or left. Initially, the bu
Harrizon [31]

Answer:

Explanation:

The following code is written in Java. It creates the Bug class with the position and direction variables. Then it creates a constructor, move method, turn method, and getPosition method. Finally, a bug object called bugsy is created in the main method, and we move it once to the right, then again to the right, and then we turn it and move it 5 times to the left, printing out the position when it is done moving. Output can be seen in the attached picture below.

class Brainly {

   public static void main(String[] args) {

       Bug bugsy = new Bug(10);

       bugsy.move();

       System.out.println("Current bug position: " + bugsy.getPosition());

       bugsy.move();

       System.out.println("Current bug position: " + bugsy.getPosition());

       bugsy.turn();

       bugsy.move();

       bugsy.move();

       bugsy.move();

       bugsy.move();

       bugsy.move();

       System.out.println("Current bug position: " + bugsy.getPosition());

   }

}

class Bug {

   char direction = 'r';

   int position = 0;

   public Bug(int initialPosition) {

       this.position = initialPosition;

   }

   public void turn() {

       if (this.direction == 'r') {

           this.direction = 'l';

       } else {

           this.direction = 'r';

       }

   }

   public void move() {

       if (this.direction == 'r') {

           this.position += 1;

       } else {

           this.position -= 1;

       }

   }

   public int getPosition() {

       return this.position;

   }

}

7 0
3 years ago
Harold wants to create a design that would depict the innocent and evil sides of human nature. Which colors can Harold use to de
belka [17]

Answer:

Usually good and evil are depicted as black and white or red and white. White being good, or pure.

Explanation:

8 0
2 years ago
In the Word 2016 window, where is the Status bar located?
Ludmilka [50]

Answer:

The Word status bar is displayed at the bottom of your document window. Just click it. You can customize if needed, just right click on the status bar.

Explanation:

6 0
3 years ago
What does this say in morse code?
Furkat [3]

Answer:

That it is time for lunch?

Explanation:

4 0
3 years ago
Read 2 more answers
What makes manually cleaning data challenging?
Alexxandr [17]

Manually cleaning data is done manually which makes it challenging. This make it prone to mistakes.

6 0
3 years ago
Other questions:
  • What piece of software tells the operating system how to use a specific hardware device? a. User interface b. System service c.
    14·1 answer
  • When discussing the data-modeling building blocks, anything (a person, a place, a thing, or an event) about which data are to be
    15·1 answer
  • When planning a backup strategy, ideally one needs to prioritize important data and only back up what is absolutely necessary fo
    15·1 answer
  • Sequential codes may be used to represent complex items or events involving two or more pieces of related data.
    7·1 answer
  • When entering a expressway using a weave lane you must do what
    7·1 answer
  • Which technique will NOT help you build rapport with your colleagues?
    15·1 answer
  • what is musical technology specifically, the origins of its genesis &amp; its importance to the baroque era
    6·1 answer
  • 01110100 01101000 01101001 01110011 00100000 01110011 01110101 01100011 01101011 01110011 00100000 01100010 01100001 01101100 01
    12·2 answers
  • Think back on the Font Tester App. Can you think of an example of another app or feature of an app which would use a loop to con
    14·1 answer
  • A(n) _______________ is a network organization that centralizes user accounts, passwords, and access to resources.
    7·1 answer
Add answer
Login
Not registered? Fast signup
Signup
Login Signup
Ask question!