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
ivann1987 [24]
3 years ago
5

Will give brainliest and good amount of points, no false answers.

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

The problem with the swap function is that it loses the value at the first index, as soon as it gets overwritten by the value at the second index. This happens in the first statement. To fix it, you need a helper variable.

First you're going to "park" the index at the first index in that helper variable, then you can safely overwrite it with the value at the second index. Then finally you can write the parked value to the second index:

var swap = function(array, firstIndex, secondIndex) {

let helper = array[firstIndex];

array[firstIndex]  = array[secondIndex];

array[secondIndex] = helper;

};

I hope this makes sense to you.

You might be interested in
안녕 또 나야 난 너에게 미래의 메시지를 전하러 왔어 01100011 01101111 01101101 01101111 00100000 01111001 00100000 01101100 01101111 00100000 01101101
sashaice [31]

Answer:

i think its 01100001

Explanation:

4 0
2 years ago
Read 2 more answers
Exercise 8.1.9: Diving Contest Your school is hosting a diving contest, and they need a programmer to work on the scoreboard! Yo
vampirchik [111]

Answer:

def calculate_score(theTuple):

    first, second, third = theTuple

    if first >= 0 and first <=10 and second >= 0 and second <=10 and third >= 0 and third <=10:

         print(first + second+third)

    else:

         print("Range must be 0 to 10")

Explanation:

This line defines the function

def calculate_score(theTuple):

This line gets the content of the function

    first, second, third = theTuple

The following if condition checks if the digits are in the range 0 to 10

    if first >= 0 and first <=10 and second >= 0 and second <=10 and third >= 0 and third <=10:

This calculates the sum

         print(first + second+third)

else:

If number is outside range 0 and 10, this line is executed

         print("Range must be 0 to 10")

4 0
3 years ago
Design a program that will receive a valid time in the 24-hour format (e.g. 2305) and convert to its equivalent 12-hour format (
coldgirl [10]

Answer:

import java.io.*;

public class Main

{

  public static void main(String[] args) throws IOException {

      BufferedReader bufferObject=new BufferedReader(new InputStreamReader(System.in));

      String stringObject=bufferObject.readLine();

      while(!stringObject.equals("99:99AM")){

      System.out.println(convertedTime(stringObject));

      stringObject=bufferObject.readLine();

      }

  }

  public static String convertedTime(String stringObject){

  String s=stringObject.substring(stringObject.length()-2);

  String[] timeObject=stringObject.substring(0,5).split(":");

  if(s.equals("AM")){

  if(timeObject[0].equals("12")) return "00"+timeObject[1];

  else return timeObject[0]+timeObject[1];

  }

  else{

  if(timeObject[0].equals("12")) return "12"+timeObject[1];

  else{

  int hours=Integer.valueOf(timeObject[0]);

  timeObject[0]=String.valueOf(12+hours);

  return timeObject[0]+timeObject[1];

  }

  }

 

  }

}

Explanation:

  • Inside the main method run a while loop until stringObject is not equal to the string "99:99AM".
  • Call the convertedTime method and display the results.
  • Use the same hours and minutes except for 12th hour If the time is in AM.
  • Use "00" instead of 12, if it is 12th hour.
  • Add hours to 12, if the time is in PM and don't change anything in case of 12.
8 0
3 years ago
1) Draw an activity diagram according to the below flow of event:
stiv31 [10]

Answer:

Yyyyttttrrttyuynynnyj6jj

6 0
3 years ago
Which of the following statements is NOT correct?
Ainat [17]

Answer: B)  Pseudocode should be properly formatted.

Explanation:

 Pseudocode is defined as in the informal description of the given sequence, there is no need that it should be formatted properly. There is no such restriction required in the pseudocode as they are read by the humans not by the computer programs.

Pseudocode should be terminating, executable and unambiguous and it uses structural convention of the programming language rather than using machine reading.

4 0
2 years ago
Other questions:
  • Which of the following commands contains an error?
    8·1 answer
  • Google Glass uses a projector that bounces a beam of light off a prism and projects the image directly on your ________. field o
    14·1 answer
  • Brian has been working for a few years now and has saved a substantial amount of money. He now wants to invest 50 percent of his
    12·2 answers
  • Organizing speech ideas according to physical space, direction, or location calls for a _____ organizational pattern.
    11·1 answer
  • When engineers consider _____, they propose giving up a benefit of one proposed design in order to obtain a benefit of a differe
    14·1 answer
  • Whats yall favv scary movie
    11·1 answer
  • A specialized output device for producing charts, maps, and very high-quality drawings is
    5·1 answer
  • Which programming scenario would most likely involve this array block?<br><br>SOMEONE PLEASE HELPPP​
    9·1 answer
  • When a user problem cannot be solved by the help desk at the first level of resolution, the problem is ___________ to the second
    7·1 answer
  • A server is handling thousands of simultaneous connections, and proxying requests to another service. Which concurrency model is
    9·1 answer
Add answer
Login
Not registered? Fast signup
Signup
Login Signup
Ask question!