Write a method smallestPositive that takes an integer array argument and returns the smallest positive element in the array.

Answers

Answer 1

Answer:

public class Main

{

public static void main(String[] args) {

    int[] arr = {28, 7, -51, -2, 221};

 System.out.println(smallestPositive(arr));

}

public static int smallestPositive(int[] arr){

    int heighest = arr[0];

   

    for(int i=0; i<arr.length; i++){

        if(arr[i] > heighest)

            heighest = arr[i];

    }

   

    int lowest = heighest;

    for(int i=0; i<arr.length; i++){

        if(arr[i] < lowest && arr[i] > 0)

            lowest = arr[i];

    }

   

    return lowest;

}

}

Explanation:

The code is in Java.

Create a method named smallestPositive that takes one parameter, arr

Inside the method:

Find the largest value in the array using the first for loop

Set the this value as lowest to find the smallest positive value (I assumed there is at least on positive value in the array)

Create another for loop to iterate through the array. If a value is smaller than the lowest and if it is greater than 0, set it as lowest

When the loop is done, return the lowest

Inside the main method:

Initialize an array with some numbers

Call the smallestPositive() with this array and print the result

(In our example, the result would be 7)


Related Questions

Write a program that uses a dictionary to store students birthdays. Your program should ask the user what their name is, and look it up in the dictionary . If their birthday is known, it should tell them their birthday.

Answers

di = {"student":"10/30/1984", "student2":"11/16/2020"}

name = input("What is your name? ")

if name in di:

   print(di[name])

else:

   print("Your name is not in the dictionary.")

You can change the values inside the dictionary. I hope this helps!

The ________ feature introduced by instant messaging shows whether a person is logged in and available to answer a question, pick up the phone, or stop by for a brief meeting.

Answers

Answer:

The correct approach is "Presence awareness".

Explanation:

The willingness, at designated occasions, to see which one is available on the internet. When using the IM framework, that very many IM systems show a list of user groups attached to the system. A current model of the IGI Social website is being used by oneself. With either the growing prevalence of Internet chat apps, a Presence Awareness model has been proposed by German IT professionals.

VOTE: STARWARS, STAR TREK, MARVEL, STRANGER THINGS. OR IT ?

Answers

i'd say stranger things or it lol

Answer: stranger things

Explanation:

Stranger things all the way

What steps should city managers and SAIC have taken at an early stage of the project to identify and prevent fraud?

Answers

Answer:

City Managers and SAIC should have avoided Switching of contract from a fixed-price contract to a time and material contracts this made the project cost to be spiraled out of control. city managers should have have avoided the switch in the terms of the contract and also implemented a project oversight that way they will identify and prevent fraud from those involved

Explanation:

To prevent fraud one needs to  identify the fraud at first . therefore the steps that should be taken by city managers and SAIC in other to Identify and prevent fraud includes ;

City Managers and SAIC should have avoided Switching of contract from a fixed-price contract to a time and material contracts this made the project cost to be spiraled out of control. city managers should have have avoided the switch in the terms of the contract and also implemented a project oversight that way they will identify and prevent fraud from those involved

in C!!
12.12 LAB: Swapping variables
Write a program whose input is two integers and whose output is the two integers swapped.

Ex: If the input is:

3 8
then the output is:

8 3
Your program must define and call a function. SwapValues returns the two values in swapped order.
void SwapValues(int* userVal1, int* userVal2)

Answers

Answer:

#include <stdio.h>

void SwapValues(int* userVal1, int* userVal2)

{

int temp = *userVal1;

*userVal1 = *userVal2;

*userVal2 = temp;

}

int main(void)

{

int a = 3;

int b = 8;

printf("Before swap: a=%d, b=%d\n", a, b);

SwapValues(&a, &b);

printf("After swap:  a=%d, b=%d\n", a, b);

return 0;

}

Explanation:

For swapping variables efficiently, you need a helper variable in C or C++.

Prove the following using the specified technique:A) Letxandybe two real numbers such thatx yis rational. Prove by contrapositive that ifxis irrational, thenx−yis irrational.B) Prove by contradiction that for any positive two real numbers,xandy, ifx·y≤50, theneitherx <8 ory <8.

Answers

Answer:

Following are the solution to this question:

Explanation:

In point A:

The predicate of the whole argument is if x+y is rational and x-y is reasonable, then x is reasonable as well" To see the sum of the two logical estimates is often sound. Let us be two real [tex]\frac{p}{9}[/tex] .rs amount then seeing how.  

[tex]\frac{p}{q}+\frac{r}{s} = \frac{(ps+rq)}{qs}[/tex] is logical, too. x Thus if[tex]x + y[/tex] is logical and [tex]x- y[/tex] is true, then [tex]x + y +x- y = 2x[/tex] should be sound.  

Let's assume [tex]2x=\frac{p}{q}.[/tex] Therefore the rational [tex]x=\frac{p}{2q}[/tex]proves the necessary statement in the query.  

In point A:

Let [tex]x \cdot y \leq 50 \ and \ x \geq 8, \ but \ \geq 8 \\\\[/tex], both to demonstrate it through contradiction. So,[tex]x \cdot y \geq 8\cdot 8 = 64[/tex]. This implies that both [tex]x \cdot y \ and \ \leq 50 \ and x \cdot y \ and \geq 64[/tex] are valid in the very same period. The argument is valid.

What is the purpose of the ISOWEEKNUM function? determines how many workdays are in a certain week determines how many workdays are in a certain month determines what day of the year that date is determines what week of the year that date is

Answers

Answer:

It's D

Explanation:

Answer:

its D on edg

Explanation:

Which program will have the output shown below?
15
16
17
>>> for count in range(17):
print(count)
>>> for count in range(15, 17):
print(count)
>>> for count in range(15, 18):
print(count)
>>> for count in range(18):
print(count)

Answers

Answer:

>>> for count in range(15, 18):

   print(count)

is the correct answer

Explanation:

How to play Drinkopoly game?

Answers

Answer:
Never heard of that lol

Explain why the process of sketching in engineering might resemble a loop or a cycle.

Answers

Answer:The process of sketching in engineering might resemble a loop because of the design process.

Explanation: The design process is a loop or cycle to improve a design. So, sketches will be shown to other engineers and they will improve on the design until it is effective and efficient.

Answer:

The correct answer includes that the idea is created in the engineer’s imagination and that he or she must sketch the image on a piece of paper in an attempt to capture the essence of the idea. Once the engineer or team sees the sketch, they may want to modify or change the design. Changes will require other sketches and further brainstorming. The cycle will continue until the engineer achieves the best possible design.

Why does the mock XYZ Health Care Provider need to define a remote access policy to properly implement remote access through the public Internet?

Answers

Answer:

Answered below

Explanation:

Remote access policies are policies that state how users can connect to organisational networks through remote access. It states the conditions and permissions required for network connection.

XYZ providers need to define remote access policies in order to ensure network security through proper authentication, control standard and documentation. A remote access policy addresses the viability of the remote user, implementation of authentication protocols, connection restrictions, remote access permissions, duration of sessions etc

In an executing process, the program counter points __________.

Answers

Answer:

To the next instruction to be executed and is incremented after each instruction has been executed.

Explanation:

Given that Program counter is a form of record or directory in a computer processor that has the location of the instruction that is currently being executed.

This it does in such a way that, following the execution of each instruction, the program counter increases the number of instructions it stored and immediately points to the subsequent instruction that follows.

Hence, in an executing process, the program counterpoints "To the next instruction to be executed and is incremented after each instruction has been executed."

How do you see the recent IT evolution (e.g. platforms, big data, Internet of Things, etc.) affect Internet security and privacy of internet users

Answers

Answer:

Answered below

Explanation:

With the evolution and growth of technology, and as we are increasingly having our everyday lives dependent on technology, there arise problems that shouldn't be ignored.

Security of people's personal data and information is of paramount importance. Access to personal information and the sale of these information to companies without the owner's permission is a breach of privacy and one of the challenges we face today.

With the growth of data, there are newer threats and attacks on software security systems to steal these data and therefore there's a need for everyday assessment and improvement in security of data.

I am writing a Python code to ask a user to enter students' information including name,
last name and student ID number. The program should continue prompting the
user to enter information until the user enters zero. Then the program enters
search mode. In this mode, the user can enter a student ID number to retrieve
the corresponding student's information. If the user enters zero, the program
stops. Please help!​

Answers

Answer:

student_file = {}

endf_input = '1'

for x in iter(list, 1):

   name = input("Enter a student name: ")

   st_id = int(input("Enter a student id number: "))

   student_file[name] = st_id

   endf_input = input("Add more student to file (type 1 for yes and 0 to end): ")

   if endf_input == '0':

       break

print("Search for Student")

search = int(input("Enter student id: "))

if search == 0:

   print("Sorry, no student with id of zero.")

   quit()

for key, value in student_file.items():

   if value == search:

       print(f"Student name: {key}")

Explanation:

The program source code uses a for loop to continuously add data to the student file dictionary structure but breaks from the loop when a zero is received as input. The program enters search mode and returns the name of the student with the searched id number.

One type of wire sequence commonly used for ethernet cables is called the ________ sequence

Answers

Answer:

100BaseT

Also called Fast Ethernet

Good luck...

Terry visits the website www.examplewebsite.org. What does the domain tell you about the site?

Answers

Answer: i can see that it is i i org site

Explanation:

Answer: the website belongs to an organization

Explanation:

Plato

"Hola! Soy Dora!" From what movie is this sentence?













Hint: parapata

Answers

Answer:

Its obivious it "Dora the Explorer"

Explanation:

On a client/server network, which computer initiates the process of assigning an IP address through DHCP?

Answers

Answer:

The client

Explanation:

On a client/server network, THE CLIENT computer initiates the process of assigning an IP address through DHCP. This is because "The Client" computer will serve as the Domain controller in which other computers of the network can find. Hence, The Client computer initiates the process of assigning IP addresses through DHCP to achieve this.

Though, in some case. A user can manually assign the IP address to computer if it is not through DHCP

where are super computer mainly used​

Answers

Answer:

they are used in astronomy as well as auto Mobile

plzzzz helpppppppppppppppppppppppppp

Answers

Answer:

Explanation:

C

Private BLANK are cloud services available to members of a particular organization.

Answers

Answer:

A private cloud is a set of applications and resources that are available only to individuals within a specific organization. These resources may be owned by the organization itself or by a third party, and may be hosted inside or outside

Explanation:

.

helpppppppppppppppppppppppppppppppppppppppp

Answers

Answer:

the can us microsoft excel

e. _______ is the standard recommended by the ITU for low bit-rate voice transmission over the Internet.

Answers

Answer:

VoIP ( Voice over internet protocol )

Explanation:

Voice over internet protocol is the standard recommended by the ITU  for low bit-rate voice transmission over the internet

VoIP is a methodology and also a group of technology used for the efficient delivery of voice communication and also for the delivery of multimedia files

Write a method named convertToArrayList() that accepts an int array as its parameter and returns an ArrayList of type Integer containing those same elements in the same order. This method stub is NOT provided for you - method name, parameter(s), and return type must match exactly to receive credit. You should not use the word static.

Answers

Answer:

Explanation:

The following code is written in Java and is a method named convertToArrayList() which takes in a preset int array and converts it into an ArrayList called myDynamicArray in the exact same order.

public static void convertToArrayList(int[] myStaticArray) {

       ArrayList<Integer> myDynamicArray = new ArrayList<>();

       for (int x = 0; x < myStaticArray.length; x++) {

           myDynamicArray.add(myStaticArray[x]);

       }

   }

A tech class question any help will be greatly apprieciated
Why would a programmer use a software artifact, such as a flowchart?

Answers

Answer:

With a code artifact, a software programmer can test the program in detail and perfect things before launching the software. The program can easily pass the testing phase for a project management artifact without any problems if errors are corrected at the level of the coding

Explanation:

:)

1 : What format would you apply to give an entry the appearance of 12-Mar-2014

Accounting Number
imput
Calendar
Date

2: When you add a columm where did it appear

Answers

Answer:

1. Date 2. It will appear to the right of the selected column.

Guys help me, to get 25 examples of computer software​

Answers

Answer:

System software is software designed to provide a platform for other software. Examples of system software include operating systems like macOS, GNU/Linux , Android and Microsoft Windows, computational science software, game engines, industrial automation, and software as a service applications.

here is the answer, well i'm really srry but I didn't put the 25 examples of computer software because i didn't do 25 but I hope I help :)

Gus is developing new software in an environment in which incremental changes are released at regular intervals within a timebox. Shana is developing software for the minimum viable product stage in order to provide the development team with feedback on how to improve the application. Gus is employing the software methodology known as __________, while Shana is employing the software methodology known as __________.

Answers

Answer:

Answered below

Explanation:

Gus is employing a software methodology known as agile while Shana is employing the minimum viable product methodology.

In agile methodology, changes are built and released incrementally within a time frame.

Therefore the software product is continuously updated.

In the minimum viable product methodology, the basic aspect of the software is released for use and feedback is received from the users thereby informing what improvements to make.

Answer: Agile, Lean

Gus is employing the software methodology known as agile, while Shana is employing the software methodology known as lean.

Write a loop that fills a list values with ten random numbers between 1 and 100. Write code for two nested loops that fill values with ten different random numbers between 1 and 100.

Answers

Answer:

Please look for your answer on Stack Overflow, it's way better.

Explanation:

In this lab, 172.30.0.0 represents the __________ network and 10.20.1.0 represents the _________ network.

Answers

Answer:

Private, public

Explanation:

In this lab, 172.30.0.0 represents the private network and 10.20.1.0 represents the public network.

Other Questions
help fast it's timed please what is the simplified form of x+6/x+4 +x-3/3 Which of the following helps you overcome the speed differential that occurs when taking notes? Read the excerpts from The Land. [Willie] turned to my daddy. "It's my boy Mitchell done this, Mister Edward, and I know there ain't no way t' make it up t' ya if this here horse don't heal right, but I jus' 'bout t' put a strap t' Mitchell my own self 'bout what he done. I'm gonna put a strap t' him right now, matter of fact!" With that said, he positioned his whip and turned toward Mitchell. *** My daddy stopped and looked at me. "No," he said. "I'm not going to whip you, Paul. No, your punishment is that you'll never get to ride Ghost Wind again. I figure you'll remember that a whole lot longer than a whipping. You won't ride any of the other horses either, including the Appaloosa, until I say so." Which statement about Willies and Mister Edwards reactions is true? Both men believe that their sons should be held accountable for their behavior. Both men believe that their sons need to learn to handle horses properly. Both men believe that their sons will likely harm the horses if they ride them. Both men believe that their sons have permanently injured Ghost Wind. what is the multiple of 9 but is also a factor of 9 write an expression in simplest form that represents the cost for shampooing and cutting w women's hair and m men's hair.Cut for women: $15Cut for men: $7Shampoo for women: $5Shampoo for men: $2 the process of dna to rna is called Can anyone do my S.S DBQ for me my email isi will give you it later it says i cant put it in i will send you a link to the document on there. in the circle shown, chords AC and BD intersect at E . if AE=8, EC=6, and BE=4. how long is DE?10121416 in which step of web design is storyboarding helpful? aCoding bEditing cPlanning dPublishing An equation is a mathematical statement composed of algebraic and/or numeric expressions set equal to each other.TrueFalse You pass 633 nm laser light through a narrow single slit of width 0.24 mm and observe the diffraction pattern on a screen 6.0 m away. If the intensity at the central bright is Io , what is the intensity at a point on the screen 3.0 mm from the center of the pattern? Will give brainest!!!!Why do we perceive reversible figures?a) The retina in the eye is influenced by the brain's cortex to interchange shapes and images.b) Our brains cannot decide on just one interpretation of a picture.c) Our brains play tricks on us when we consume too much caffeine.d) Sensory information comes in too fast for us to target just one figure. Describe the path of blood flow through pulmonary and systemic circulation. Online Content Site:1 Why was it important to Charlemagne to unify Europe during his reign? Use complete sentences answers fast please! How many phonemes are there in the word dogs? A. four B. three C. two D. one Please select the best answer from the choices provided A B C D A submarine is at a depth of 30m. It descends another 20m and then rises40m. What is its final depth? X-3y=9 into a slope intercept form Given An = 5a(n-1) where a1= 2. What are the first 4 terms