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
navik [9.2K]
2 years ago
15

Consider the following incomplete method. Method findNext is intended to return the index of the first occurrence of the value v

al beyond the position start in array arr. I returns index of first occurrence of val in arr /! after position start; // returns arr.length if val is not found public int findNext (int[] arr, int val, int start) int pos = start + 1; while condition '/ ) pos++ return pos; For example, consider the following code segment. int [ ] arr {11, 22, 100, 33, 100, 11, 44, 100); System.out.println(findNext (arr, 100, 2)) The execution of the code segment should result in the value 4 being printed Which of the following expressions could be used to replace /* condition */ so that findNext will work as intended?
(A) (posarr.length) &&(arr [pos]- val)
(B) (arr [pos] != val) && (pos < arr. Îength)
(C) (pos (D) (arr [pos} == val) && (pos < arr. length)
(E) (pos
Computers and Technology
1 answer:
inna [77]2 years ago
8 0

Answer:

B)

Explanation:

The while loop runs as long as two conditions are satisfied, as indicated by the && logical operator.

The first condition- arr[pos] != val

checks to see if the value in the array index, pos, is equal to the given value and while it is not equal to it, the second condition is checked.

The second condition(pos < are.length), checks to see if the index(pos) is less than the length of the array. If both conditions are true, the program execution enters the while loop.

The while loop is only terminated once arr[pos] == Val or pos == arr.length.

You might be interested in
1. JAVA Create one method to do the following expressions. Given the following declarations, what is the result of each of the e
nordsb [41]
<span>public void myMethod(int w, int y, int z) {
</span>int a, b, c, d, e, f, g, h, i, j, k, l;

<span>a = w * z;
</span>b = w * z + y;
c = w * -z;
d = w * --z + y++;
e = w * z-- + ++y<span> ;
</span>f = w + z * y;
g =  w – y + z;
h = (w + y) * z;
i = y / w;
j = y / z;
k = w % y;
<span>l = y % w;
</span>System.out.println( "%d %d %d %d %d %d %d %d %d %d %d %d", a,b,c,d,e,f,g,h,i,j,k);
}

To use 
myMethod(2, 7, 12);
7 0
3 years ago
Often an extension of a memorandum of understanding (MOU), the blanket purchase agreement (BPA) serves as an agreement that docu
Alchen [17]

Answer:

FALSE

Explanation:

The blanket purchase agreement (BPA) can not serves as an agreement that documents the technical requirements of interconnected assets but the Interconnection service agreement (ISA).

3 0
3 years ago
Online education students need to be taught
weeeeeb [17]

Online education is a teaching practice delivered through the internet. The students learning from online platforms must be taught to be ethical.

<h3>What is the importance of ethics and integrity?</h3>

In the online education system, the students should learn to be ethical and integral as it enables the students and their teachers to be creative, free to create ideas, and acknowledge others' work.

Ethics teaches the students to develop their personalities and behavior. Students' integrity allows them to be honest, responsible, and fair towards their work and instructor.

Therefore, option A. online learning students must be taught to be ethical.

Learn more about online learning here:

brainly.com/question/14708323

#SPJ1

7 0
2 years ago
Question # 6
nika2105 [10]

Answer:

14.0

Explanation:

The loop converts each answer to a float. The accumulator variable adds the values entered.  

2.0 + 5.0 + 1.0 + 6.0 = 14.0

3 0
3 years ago
Read 2 more answers
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
Other questions:
  • To find a webpage, the user of a search engine would simply enter a word or phrase in the resource's text box. what is the term
    11·1 answer
  • Match the terms with their definitions.
    5·2 answers
  • What is the most likely result of making a plan for life after high school
    14·1 answer
  • In the code segment below, assume that the int variable n has been properly declared and initialized. The code segment is intend
    5·1 answer
  • You have a large TCP/IP network and want to keep a host's real time clock synchronized. What protocol should you use?
    10·1 answer
  • Can anyone help me this is due today :) <br> Thank you so much
    14·2 answers
  • If you hard working right now go to this EASY question
    9·2 answers
  • What skills did Carl work on, and what steps did he take to reach his long term goals?<br>​
    10·1 answer
  • 1- pensamiento sistémico<br>2- visión oriental y occidental​
    8·1 answer
  • Write a complete program that declares an integer variable
    7·1 answer
Add answer
Login
Not registered? Fast signup
Signup
Login Signup
Ask question!