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
agasfer [191]
3 years ago
8

Code scramble: make the program sort the three numbers x, y and z into increasing order, so that x has the smallest value, y has

the next smallest value, and z has the largest value. Drag and drop with your mouse to rearrange the lines.
Engineering
1 answer:
riadik2000 [5.3K]3 years ago
3 0

Answer:

This question is taken from code scramble exercise which has scattered lines which are to be arranged by dragging and dropping with mouse to  to get the desired output in which x has the smallest value, y has the next smallest value, and z has the largest value. So the correct arrangement is as following:

tmp=max(x,y)  

x=min(x,y)  

y=tmp  

tmp=max(y,z)  

y=min(y,z)

z=tmp  

tmp=max(x,y)  

x=min(x,y)  

y=tmp

Explanation:

So the flow works as following:

First the maximum of x and y is taken and the result is stored in a temporary variable tmp which is used so that the original values do not get affected or modified by the operations performed by the functions. Lets say that x=30 y=15 and z=40

Now the max() functions returns the maximum from the values of x and y. As x=30 and y=15 so value of x is stored in tmp which is 30 as 30>15

Next the min() function finds the minimum from the values of x and y and stores the result in x. As the minimum value is 15 so this value is stored in x and now x=15

y = tmp means now the value in tmp is copied to y, So y = 30

Next the max() function finds the maximum value from the values of y and z. As y=30 and z=40 So the maximum value is 40 so tmp variable now contains the value 40.

Next the min() function finds the minimum from the values of y and z and stores the result in y. As the minimum value is 30 so this value is stored in y which means y remains 30 so, y=30

z = tmp means now the value in tmp is copied to z, So z= 40

Now the max() functions returns the maximum from the values of x and y. After the operations of above functions the new value of x and y are: x=15 and y=30 so value of y is stored in tmp which is 30 as 30>15

Next the min() function finds the minimum from the values of x and y and stores the result in x. As the minimum value is 15 so this value is stored in x and x remains: x=15

y = tmp means now the value in tmp is copied to y, So y remains: y = 30

So the final values of x, y and z are:

x = 15 y = 30 z = 40

If you want to make a program which sort the values in x, y and z then i am providing a simple Python program that serves the purpose:

x = int(input("enter first number: "))

y = int(input("enter second number: "))

z = int(input("enter third number: "))

a1 = min(x, y, z)

a3 = max(x, y, z)

a2 = (x + y + z) - a1 - a3

print("x =",a1,"y=",a2,"z=",a3)

The program asks user to enter the value for x, y and z.

Then the minimum value from the values of x,y and z is computed using min() function and the result is stored in a1. This will be the value of x. Then the maximum value from value of x,y and z is computed using max() function and the result is stored in a2. This will be the value of z. Next the statement: a2 = (x + y + z) - a1 - a3  works as following:

Lets say the values of x = 30 y = 15 and z = 40 So a1 = 15 and a2 = 40

a2 = 30 + 15 + 40 - 15 - 40

a2 = 30

This is the value of y

So  print("x = ",a1,"y = ",a2,"z = ",a3) displays the following output:

x = 15 y = 30 z = 40

You might be interested in
Determine the time required for a car to travel 1 km along a road if the car starts from rest, reaches a maximum speed at some i
lbvjy [14]

Total time taken by car to travel 1 km distance is 48.2 seconds

Explanation:

Given data-

Total distance- 1 km= 1000m

Car starts from rest- Hence the initial velocity (u)= 0 m/s

Then, car accelerates at 1.5 m/s ²

Let us suppose with these acceleration car reaches the max speed of V

Car then decelerates at rate of 2 m/s ²

Finally, car comes to rest

We need to consider the question in two parts

Part 1= when car starts from rest and reaches the value V in the time tₐ at the distance s₁.

Part 2= When car starts from V and finally stops at 1 km mark in the time tₙ in distance 1000-s₁.

For the part 1

We know the formula  

v= u + a*tₐ

where v= final velocity

u- initial velocity

a= acceleration

tₐ= time period

At the starting u= 0  

Hence the equation reduces to V=0+1.5tₐ

Or V= 1.5tₐ                             Eq 1

We also know that s= u*tₐ+ ¹/₂*a*tₐ²

Where s₁= distance covered  (other symbols same meaning)

Since u=0   (u*tₐ=0)

s₁ = ¹/₂*1.5*tₐ²

s₁= ½* 1.5*tₐ²                    -------------Eq 2

Now considering Part 2

Here the case is deceleration hence the equation would change (symbols same)

v= V-a*tₙ     final velocity(v)=0 (car stops finally) & initial velocity (part 2)= V

V= a*tₙ

V=2*tₙ                                 -----------Eq 3

Similarly  

1000-s₁= V* tₙ+¹/₂*(-2) *(tₙ)²

1000-s₁= V* tₙ-tₙ²                      -------Eq 4

Comparing Eq 1 and Eq 3

V= 1.5tₐ  and V=2tₙ                                                              

1.5tₐ = 2 tₙ

tₐ=1.33 tₙ  

Using the above value of tₐ in Eq 1

V= 1.5 tₐ and tₐ= 1.33 tₙ

V= 2tₙ

Similarly from Eq 2 and putting the value of tₙ

s₁= ½*1.5*tₐ²      

s₁=  1.33*(tₙ)²

Substituting the above values in equation 4

1000-s₁= V* tₙ-tₙ²                      

1000- 1.33(tₙ)²=2*(tₙ)*(tₙ)- tₙ²

1000=2.33 (tₙ)²

tₙ=      1000/2.333    

tₙ= 20.7 sec

Similarly putting the value of tₙ in tₐ= 1.33 tₙ

tₙ= 27.5 sec

Hence total time is tₐ +tₙ  

T= 20.7+27.5= 48.2 sec                

8 0
3 years ago
Choose two consumer services careers and research online to determine what kinds of professional organizations exist for these p
Tom [10]

Answer:

Market Researcher

The Marketing Research Association (MRA) is a professional organization for market researchers. It provides information to its members on how to improve marketing research for businesses and individuals. The MRA gives its members important industry news and information through their website. Their code for marketing research standards also protects members from bad actors and improves the public perception of marketing research. The association also has a full time lobbyist representing the market research industry before government officials. The MRA has various membership categories as well. The membership fee differs for each category.  

Credit Analyst

A credit analyst is a person that reviews consumer or business financial profiles in order to give a loan or credit to them. When a business or individual applies for a credit card, loan, trade account, or another type of financial product whereby a company allows them the use of their money, a credit analyst’s job is to ensure that the consumer or business is willing and able to pay it back in the future. Credit analysts use tools such as credit reports, FICO scores, Dun & Bradstreet ratings, financial statement analyses, and personal references to perform their job. A credit analyst should have a bachelor’s degree with a major in business. Finance and economics majors are particularly suited to a credit analyst position. Certifications are not required, but some credit analysts pursue CPA or CFA (Certified Financial Analyst) designations.

Explanation:

5 0
3 years ago
Fill in the blank to output the quotient of dividing 100 by 42. print (100______42)​
kondaur [170]

Answer:

print(100/42)

Explanation:

This is the operand for division in python and some other languages.

6 0
3 years ago
Among Us Map-Skeld Imposter 3 code- DBZPTQ
Yuki888 [10]

Answer:

0:  <em>NOICE  </em>:0

Explanation:

7 0
3 years ago
Read 2 more answers
The percentage modulation of AM changes from 50% to 70%. Originally at 50% modulation, carrier power was 70 W. Now, determine th
adoni [48]

Answer:

What is percentage modulation in AM?

The percent modulation is defined as the ratio of the actual frequency deviation produced by the modulating signal to the maximum allowable frequency deviation.

3 0
3 years ago
Other questions:
  • Which BEST identifies a contrast in these two passages? A) The actions taken by the bird in the poem cause injuries, but the act
    5·1 answer
  • Women make up about 20% of the workforce in the aviation industry. With such a small percentage of female employees, JetBlue mus
    8·2 answers
  • A socket can be driven using any of the following except for (A) a socket ratchet
    14·1 answer
  • The natural water content of a Boston Blue Clay soil sample was found to be 14.6% through oven drying. It has been calculated th
    8·1 answer
  • During an experiment conducted in a room at 25°C, a laboratory assistant measures that a refrigerator that draws 2 kW of power h
    13·1 answer
  • Whats better Chevrolet or Ford
    12·2 answers
  • What types of information are provided in the invitation to bid?
    7·1 answer
  • Coderz robotics 101: challenge mission 3 part 3
    8·1 answer
  • Sylvie has a robot that helps her wash dishes. Which of the following must be true?
    5·1 answer
  • The only difference between all GMA welding machines and some FCA welding machines is that all GMA welding machines must have a
    14·1 answer
Add answer
Login
Not registered? Fast signup
Signup
Login Signup
Ask question!