Pseudocode to java

Can you write this in Java program

Binary Search

Pseudocode To Java Can You Write This In Java ProgramBinary Search

Answers

Answer 1

Answer:

class Main {

 public static void main(String[] args) {

   int[] values = {11,12,15,16,112,118,123,145};

   int target = 15;

   int min = 0;

   int high = values.length-1;

   boolean found = false;

   int answer = 0;

   int mid;

   while(!found && min <= high) {

     mid = (min + high) / 2;

     if (values[mid] == target) {

       found = true;

       answer = mid;

     } else if (target > values[mid]) {

       min = mid + 1;

     } else {

       high = mid - 1;

     }

   }

   if (found) {

     System.out.printf("%d FOUND AT ARRAY INDEX %d", target, answer);

   } else {

         System.out.printf("%d was not found", target);

   }

 }

}

Explanation:

I altered the while expression to make the code work.

Answer 2

Answer: class Main {

public static void main(String[] args) {

  int[] values = {11,12,15,16,112,118,123,145};

  int target = 15;

  int min = 0;

  int high = values.length-1;

  boolean found = false;

  int answer = 0;

  int mid;

  while(!found && min <= high) {

    mid = (min + high) / 2;

    if (values[mid] == target) {

      found = true;

      answer = mid;

    } else if (target > values[mid]) {

      min = mid + 1;

    } else {

      high = mid - 1;

    }

  }

  if (found) {

    System.out.printf("%d FOUND AT ARRAY INDEX %d", target, answer);

  } else {

        System.out.printf("%d was not found", target);

  }

}

}

Explanation:

I altered the while expression to make the code work.


Related Questions

Int[] myArray1= new int[24]; int[] myArray2= new int[10]; float[] myArray3= new float[8]; int index1, index =0 for(int index1 =0; index1<24; index1++){ myArray1[inex1]=index1*2; index2=index1%10; index3=index1%8; myArray2[index2] = index3 + index 2 + myArray1[index1]; myArray3[index23 = myArray1[index2] + index3;

Answers

Answer:

The value of myArray2[index2] when index1 = 12 is 30

Explanation:

In the source code, the formula for myArray2[index2] is;

   myArray2[index2] = index2 + index3 + myArray1[index1],

   myArray1[index1] = index1 * 2,

   index2 = index % 10 (equal to the remainder) and

   index3  = index % 8

When index1 increases to 12 in the for-loop statement, the "myArray1[index1]" is equal to 24, index2 is equal to 2 and index3 is 4. The total sum is equal to 30 and assigned to "myArray2[index2]".

1. i am allergic to eggs
2. my doctor said to eat les sodium
3. i’m trying to say money
4. i want to post a nice picture of it online

can u put the number for which ones so i don’t get confused. the ones i put are the names for the number please and thank you


Recommending a Meal
You will be recommending meals for several people based on a set of data. Each person will tell you something to help
you decide which meal is the best. You will recommend a meal, then explain your choice based on the data that you
have been given. Your data is on a separate page.

Answers

Answer:

make an outline and trust me you will do it by yourself

Edhesive Intro to cs quiz 2 q#9

What is output?
Print (3 % 15)
Thanks!!

Answers

Answer:

5

Explanation:

AS we know that % is the sign of division in C language when we divide the 3 into 15  its 5

Answer:

5

Explanation:

How are “cells” in a spreadsheet formed?

Answers

Cell: A cell is a rectangular area formed by the intersection of a column and a row. ... For example the cell in Column "C" in Row "3" would be cell C3. Column: Columns run vertically on the spreadsheet screen. An Excel spreadsheet contains 256 columns that are labeled with the letters of the alphabet.

Answer:

Mitosis

Explanation:

New cells are created from a process called cell division. The new cells are produced when a cell, called the mother cell, divides into new cells called daughter cells. When two daughter cells have the same number of chromosomes as the original cell, the process is called mitosis.

The terms Apps and Applications can be used interchangeably about software installed
on both computers and mobile devices. True or False

Answers

Answer:

False

Explanation:

Hope this helps and have a great day!!!!


What is the advantage of a surge protector over a power strip?

Answers

Answer:

When the voltage increases above the norm for at least 3 nanoseconds, the heat generated in the arc can fry your electronics and damage your electrical outlets. A surge protector evens out the sudden peaks of electricity; thus, protecting your electronic devices against random power spike damage.

Explanation:

PLZ HELP

Alejandro decided to save some time by copying and pasting code into the editor, but the program didn’t work. What is the most likely explanation for this?


A.

There was no binary converter.


B.

Interpreters can’t read symbols from a different font.


C.

There was no code editor available.


D.

There was an error in the original code.

Answers

Answer:

B needed points but its right

;)

Explanation:

A professional interpreter's job is to make it possible for two or more parties who speak different languages to communicate with one another. Because of this, qualified interpreters are limited to translating spoken words. Thus, option B is correct.

What Interpreters can’t read symbols from a different font?

Their responsibilities include accompanying clients on trips to help them communicate with others who speak different languages, translating speeches or presentations for audiences that are multilingual, and assisting with the conversion of spoken words into written communications.

Add > Symbol > Additional Symbols. Select the symbol in the resulting window, but also double-check that the font is set to your usual font on the line at the upper left. After that, type your shortcut. The symbol ought to display in the specified font when you use the shortcut.

Therefore, Interpreters can’t read symbols from a different font.

Learn more about font here:

https://brainly.com/question/7971447

#SPJ2

What does the “MIN” and “MAX” functions allow you to do when inserted in a spreadsheet?

Answers

Answer:

Please see explanation

Explanation:

A spreadsheet is used to make calculations and payrolls etc. Different functions are used in spreadsheet. Two of them are MIN and MAX.

The MIN function gives the minimum value out of all the cells in the range.

It is written as:

= MIN(number1, number2..)

OR

= MIN(Starting_cell_address:Last_cell_address)

Similarly, MAX function gives the maximum value from the selected range of cells.

= MAX(number1, number2..)

OR

= MAX(Starting_cell_address:Last_cell_address)

PLEASE HELP ME! Consider the block of code below. When will the value of s be equal to 5? (Java Programming) (3 points)

if(isFemale)
s = 5;
else
s = −161;

a. isFemale equals 5
a. isFemale equals 'F'
c. isFemale equals "F"
d. isFemale equals true
e. isFemale equals −161

Answers

Answer:

d. isFemale equals true

Explanation:

I believe that the answer would be d: isFemale equals true. I am an AP Computer Science Principles student this year, and when we code apps we use "if else" blocks, and if the "if" statement is true, then the code will follow through with the "if" section. If not, then it will follow through with the "esle" section.

Therefore, if (isFemale) is true, the code would follow that section, and have s=5.

I hope this helps! :)

A shop has a sale that offers 40% off all prices.
On the final day they reduce all the sale prices by 20%.
Linz buys a radio on the final day.
Work out the overall percentage reduction on the price of the radio.​

Answers

Answer: 52%

Explanation:

First they reduced the prices by 40% so now the prices are 60% of their original price.

They then reduced it by a further 20%.

= 20% * 60%

= 12%

Total reduction = 40% + 12%

= 52%

Taking a recipe and breaking it down into its individual sections, like ingredients, preparation, cooking instructions, and nutritional information, is an example of _____.

refinement

pattern recognition

decomposition

abstraction

Answers

Answer:

its C - Decomposition

Explanation:

100% edge

Fruits and vegetables lose some of their vitamins and phytonutrients, which are healthy plant molecules other than vitamins and minerals. The amount of nutrients destroyed increases with cooking time and temperature. Some nutrients can even start to be lost during food preparation. Thus, option C is correct.

What cooking instructions, include decomposition?

Boiling results in the greatest loss of nutrients, while other cooking methods more effectively preserve the nutrient content of food. When it comes to preserving nutrients, stir-frying, roasting, and steaming are some of the best ways to prepare vegetables.

There are three different sorts of cooking techniques: combination cooking, moist heat cooking, and dry heat cooking. Heat is used in each of these techniques to modify food uniquely. These three ways can be used to categorize all forms of cooking, including grilling and steaming.

Therefore, taking a recipe and breaking it down into its individual sections, like ingredients, preparation, cooking instructions, and nutritional information, is an example of (decomposition).

Learn more about cooking here:

https://brainly.com/question/5190639

#SPJ2

Can a WiFi router see if your device is active if the cell radio is disconnected but the WiFi is on? (Which can be done using an APK or ADB command.)

Answers

Answer:

I don't think so... it shouldnt be able to... considering the cell radio is off

Which of the following does not represent the function of a Variable? Variables store data in memory; this data has limited use throughout a program.
Variables are used to store information that is referenced and manipulated in a computer program.
Variables provide a way of labeling data with a descriptive name
Variables are containers that hold information.

Answers

Answer:

Variables store data in memory; this data has limited use throughout a program.

Explanation:

In Computer programming, a variable can be defined as a placeholder or container for holding a piece of information which can be modified or edited.

Basically, variable stores information which is passed from the location of the method call directly to the method that is called by the program.

Some of the function of a Variable includes;

I. Variables are used to store information that is referenced and manipulated in a computer program.

II. Variables provide a way of labeling data with a descriptive name. This helps to make programming codes to be clear and easy to understand for everyone.

III. Variables are containers that hold information.

Generally, variables are essential in writing codes because they are used to label and logically store data in contiguous memory locations.

Hence, variables store data in memory; this data can be used throughout the program i.e they do not have limited use throughout a program.

Can someone help me plz

Answers

Answer:

ok but on what tho

Explanation:

plz explain yourself

the second one would seem like the most logical answer I’m guessing, this is just an educated guess but I hope it can help:)

Fill in the blank with the correct term.
A _____ sort starts by comparing the first item in the list to the remaining items, and swaps where the first item is greater than the later item.
Then it compares the second item in the list to the rest.
This continues until it compares the second last item to the last item.

Answers

Its bubble sort!!! Thats my final answer! Youre welcome

UNA GRUA NECESITA LEVANTAR UN PALE DE SACOS DE CEMENTO QUE PESA 5000N ,¿A QUE DISTANCIA SE DEBE SITUAR EL PALE

Answers

Answer:i no speak espanol

Explanation:   f

What does the following line of code do? Assume the user enters 2.3.

answerA = input("Enter a number. ")

It stores an int in the variable.

It stores a string in the variable.

It stores a float in the variable.

This line of code causes an error.

Answers

Answer:

It stores an int in the variable.

Explanation:

Answer:

It will store an int (Integer) into the variable.

Explanation:

Edg 2021

Which of these lines of code will increment a variable?

A.
print(variable)

B.
count(variable)

C.
inc(variable)

D.
variable = variable + 1

Answers

Answer:

D

Explanation:

Answer:

D.

Explanation:

I got it right on the test.

Edhesive 6.7 code practice

Answers

For the happy code put a happy face and so on and so forth. There isn't much people,e can do to help with these type of questions. A bit more detail is always appreciated for the people answering questions


Which technology concept uses computer resources from multiple locations to solve a common problem?

Answers

Answer: Sounds like you are talking about “Distributed memory systems” which use multiple computers to solve a common problem, with computation distributed among the connected computers (nodes) and using message-passing to communicate between the nodes.

What is typeface
A. A family of fonts in a certain style
B. The spacing between individual letters
C. The tapered feature at the end of strokes
D. The logo and tagline that represent a company
E. The spacing between lines in a paragraph

Answers

Answer:

the answer is A - family of fonts.

Explanation:

plato/edmentum users! i got it correct on the test.

What are the benefits of writing functions that use parameters and return? Try to list at least two.

Answers

Answer:

Explanation:

Writing functions that use parameters and return helps improve code readability and manages complexity by reusing code.

By repeating code and creating methods that utilize arguments and return, you may increase readability of code and control complexity. Instead of creating two distinct functions, parameters may be used to mix the two.

Parameters and results of the tests enable us to build code that is more readable and adaptable to a wider range of contexts. However, we'll need to practice reading, developing, and troubleshooting code like this because it operates a little more than the programmed we're used to.

Learn more:

https://brainly.com/question/15260986?referrer=searchResults

What tab group would you use to
change the format of cell A2 to match
cell A3?
O Cells
O Styles
O Font
O Alignment
O Number

Answers

Answer:

number......................

The tab group that would you use to change the format of cell A2 to match cell A3 is style. The correct option is B.

What is cell format?

The Format Cells pop - up window has six tabs: Total count, Alignment, Font, Border, Patterns, and Protection.

The Format Cells feature allows users to change the formatting of one or more cells and/or the appearance of their values in the sheet without changing the numbers themselves.

The Format Cells contain a number of control options that allow users to change the view of the displayed data within the cells.

A cell value can be one of four types: empty, numeric, text, Boolean, or error. Cell values can be displayed in a variety of ways.

Choose the cells. Choose a style from Home then Cell Style.

Thus, the correct option is B.

For more details regarding cell format, visit:

https://brainly.com/question/24139670

#SPJ6

Which type of cryptography uses two mathematically linked keys, one key encrypting the data and the other decrypting the data?
Asymmetric
Encoding
Firewall
Symmetric

Answers

Answer:

Asymmetric.

Explanation:

Encryption is a form of cryptography and typically involves the process of converting or encoding informations in plaintext into a code, known as a ciphertext. Once, an information or data has been encrypted it can only be accessed and deciphered by an authorized user.

Some examples of encryption algorithms are 3DES, AES, RC4, RC5, and RSA.

There are two (2) main types of encryption techniques used in cryptography and these are;

I. Symmetric encryption.

II. Asymmetric encryption.

Asymmetric encryption is a type of cryptography which uses two mathematically linked keys, one key encrypting the data and the other decrypting the data. These two keys are generally referred to as a public key and a private key respectively.

This ultimately implies that, a pair of key (two keys) that are different in values is required or needed to make a computer system secured.

Please help! Here is the question and the answer choices.

Answers

It should be Line 06

Answer:

It is line 3. Line 3 is supposed to be hasNegative >- true.

Explanation:

It is line 3 because the hasNegative <- true doesn't make any sense. It is supposed to change into hasNegative >- true because if the list contains a negative number, it should return as true. But hasNegative <- true means the opposite.

Hope it helped!

stay safe and search answers up if you need ​

Answers

Answer:

Yes, Thank you

Jesus loves you!!

Explanation:

A digital presence created online by an individual or organization using a digital device is called a identity.

Answers

Answer:

A digital presence created online by an individual or organization using a digital device is called a digital identity.

Explanation:

A pizza delivery restaurant decides to stop hiring drivers and start hiring cyclers to deliver its pizza. The restaurant thinks this will cut costs because it will not have to pay for gas. This is an example of which of the following supply chain management drivers?


A. information

B. facilities

C. transportation

D. inventory

Answers

Answer:

C. i think im sorry if  im wrong plz forgive

Which of the following is a legal variable name?
A) O temperatureAM
B) 52
C) 1test
D) #data

Answers

Answer:

D #data

Explanation:

A) O temperatureAM is a legal variable name.

While in the Current View command group for notes, which view options do you have available? Check all that apply.

Answers

Answer: A, B, C (is this for a Microsoft class?)

Explanation: Edge

Answer:

Icon

Note list

Last 7 days

Explanation:

Other Questions
Solve for x.log(x+22)-log(x-2)=2 When a customer in Japan was quoted a price of .39 cents a pound he thought he was being charged .39 a kilogram. He was shocked when he go the bill since he ordered 100kg. How much was the bill? ((((((ASAP))))))On Tuesday afternoon at camp, Finn did archery and sailing before dinner. Archery started at 12:10 P.M. Finn spent 1 hour and 25 minutes at archery and 40 minutes sailing. What time did sailing end?Include A.M. or P.M. in your answer (for example, 11:58 A.M.). HELP HELP please. Im failing i genuinely need help im begging you What explorer discovered a way around the African southern tip? s company recently experienced a major system outage due to the failure of a critical component. During that time period, the company did not register any sales through its online site. Which type of loss did the company experience as a result of lost s Anyone know a good sales pitch for Dynamite? A right rectangular prism is 4 m long, 5 m wide, and has a height of 6 m. What is its surface area?120 m 2240 m 276 m 2148 m 2 PLEASE GO TO MY PROFILE AND ANSWER MY OTHER QUESTION CORRECT ANSWER GET BRAINLY There are 100 performers in a dance recital. The ratio of men to women is 4 : 6. How many performers in the dance recital were men? Identify the quadrant or axis that the following point lies on. If the point lies on an axis, specify which part (positive or negative) of which axis (x ory).(-2,-5) Who wrote Ashoka's Rock andPillar Edicts? Pls Help Thanks in advance John and Jake are working at a car wash. It takes John 1 hour to wash 3 cars; Jake can wash 3 cars in 45 minutes. If they work together, how many cars can they wash in an hour? Sula only purchases stock in corporations that produce environmentallyfriendly goods. Which term refers to Sula's type of investment?A. Socially responsibleB. Financially constrainedC. Risk-takingD. Technically analyzed A m ____ gusta beber agua.1. Te2. Le3. Me4. Les rate us 1 to 10!!!!!!!! Please help due in 10 minutes Cos G =5/1212/135/1312/5 Shakespeare's plays were primarily performed at night in enclosed theatres.True or False A family purchased tickets for a concert and paid a total of $70. They purchased 4 child tickets and 3 adult tickets. If an adult ticket were twice as expensive as a childs ticket, what was the cost of a childs ticket? (Please write the equation)