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
Strike441 [17]
3 years ago
5

Given the integer variables x and y, write a fragment of code that assigns the larger of x and y to another integer variable max

.
Computers and Technology
1 answer:
Sidana [21]3 years ago
7 0

Answer:

if ( x > y ) {

    max = x;

}

else {

    max = y;

}

Explanation:

Assumptions:

(i) Variables x, y and max have been defined.

(ii) Since the question does not specify what to do if x and y are equal, I have assumed no such case exists. i.e x and y are never equal.

PS : The code has been written in Java.

According to the question, the larger of variables <em>x</em> and <em>y</em> is assigned to another variable, <em>max.</em>

To check which of x and y is greater, we could use an <em>if...else</em> statement like so;

if ( x > y ) {      // check if x is greater than y

  max = x;      // if yes, assign the value of x to max

}

else {             // then y is greater

 max = y;      // assign the value of y to max

}

You might be interested in
Question 1 (True/False Worth 3 points)
ANTONII [103]
False because the internet connects with multiple communication networks to exchange information
6 0
2 years ago
By default, the windows desktop display
MrRissso [65]
By default, the windows desktop display the following icons/programs

1. Your Recycle Bin
2. My Computer
3. The Internet Explorer
4. The default Windows Background
5. Your windows menu
6. My Documents
7. Your task bar
8. Time (located at bottom right)
6 0
3 years ago
What does a bonus object do? A. Subtracts lives B. Keeps track of a player's health C. Gives a player an advantage D. Makes text
lyudmila [28]

Answer:

C) Gives a player an advantage

Explanation:

I don't know the context of the question, but it makes the most sense.

5 0
3 years ago
What is BINARY it is making get confused
enot [183]
It is a number that is expressed in the binary numerical system
6 0
3 years ago
Explain why a single 500 kg block of granite weathers much more slowly than 100 chunks of granite weighing 5 kg each.
Bad White [126]
Weathering occurs on the surface of rocks, and lots of small rocks have a much greater surface area than one big rock.
3 0
3 years ago
Read 2 more answers
Other questions:
  • Safety interlock module operates by monitoring the voltage from the
    7·1 answer
  • What is IaaS? For this service model, what are the resources the cloud vendor will provide/manage and what are the resources the
    15·1 answer
  • How to wire two separate switches &amp; lights using the same power source?
    14·1 answer
  • Swiping and pinching are graphical user interface (gui) _____________.
    7·2 answers
  • Lan is working on a project report that will go through multiple rounds of
    10·1 answer
  • Which one of these do you need to become president of the US ?
    6·2 answers
  • Write a program that reads in an integer, and breaks it into a sequence of individual digits. Display each digit on a separate l
    14·1 answer
  • Identify the hardware components in your own computer. If you don't have a computer, use a friend's, or one at work or in an NVC
    5·1 answer
  • Which of the following is a type of input device?
    5·1 answer
  • This ingredient is often used as decoration for both hot and cold dessert​
    7·1 answer
Add answer
Login
Not registered? Fast signup
Signup
Login Signup
Ask question!