answer.
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
charle [14.2K]
2 years ago
12

A function defined beginning with void SetNegativesToZeros(int userValues[], ... should modify userValues such that any negative

integers are replaced by zeros. The function _____.
Computers and Technology
1 answer:
Stels [109]2 years ago
3 0

Answer:

   public static void setNegativesToZero(int userValues[]){

       System.out.println("Array before setting negatives to zero "+Arrays.toString(userValues));

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

           if(userValues[i]< 1){

               userValues[i] = 0;

           }

       }

       System.out.println();

       System.out.println("Array After setting negatives to zero "+Arrays.toString(userValues));

   }

Explanation:

Using Java programming Language, the method is created to receive an array of ints as parameter (as specified in the question)

Using a for loop, we iterate over the entire array checking for values that are negative (<0) and setting them to zero.

See a complete program below

import java.util.Arrays;

import java.util.Scanner;

public class num1 {

   public static void main(String[] args) {

   // Create an array and assign values

       int [] arr = {1,2,3,-1,1,2,-4};

   //Calling the method setNegativesToZero

   setNegativesToZero(arr);

   }

//Creating the Method

   public static void setNegativesToZero(int userValues[]){

       System.out.println("Array before setting negatives to zero "+Arrays.toString(userValues));

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

           if(userValues[i]< 1){

               userValues[i] = 0;

           }

       }

       System.out.println();

       System.out.println("Array After setting negatives to zero "+Arrays.toString(userValues));

   }

}

You might be interested in
your company decides to implement a RAID-5 array on several file servers. Which feature is provided by this deployment
Novay_Z [31]

Answer:

High availability

Explanation:

RAID-5 array is defined as a redundant array for independent disk configuration which makes use of the disk striping with the parity. It consists of a minimum three disk drives and it uses the data striping and the parity data to provide the redundancy.

RAID 5 is a powerful tool to ensure integrity of the data. It provides both performance as well as security to the data.

In the context, "high availability" is the feature that is provided by the deployment of RAID 5 array on the several file services.

4 0
1 year ago
Which of the following commands uses correct syntax for matching the patterns bunk or bank at the end of a line of text?
Alika [10]

Answer:

a. grep 'b[au]nk$' myLine

Explanation:

grep is a command used for searching a specified pattern in a given text.

Our goal is to match the character sequence - bank or bunk at the end of line in a  given line referenced by myLine.

The regular expression for the specified match criterion is:

b[au]nk$

The second character can be either a or u.

$ indicates match at end of line.

So the overall grep command is :

grep 'b[au]nk$' myLine

8 0
1 year ago
The base class Pet has private fields petName, and petAge. The derived class Dog extends the Pet class and includes a private fi
Lapatulllka [165]

Answer:

Hello attached is the Java program written to solve the problem

The Pet.java and Dog.java files are unaltered

Explanation:

The input and output  codes are attached as well i.e the second image is the input while the third image is the output code

5 0
2 years ago
Charlie has a large book collection. He was keeping track of it in a spreadsheet, but it has grown big enough that he wants to c
zepelin [54]

Answer:

Check the explanation

Explanation:

Ans 1) storing the data in one single row comes with its own barriers and that is if you delete one of the record in the spreadsheet, all the equivalent records which you didn't wanted to delete would be deleted. For take for instance, if you wish to delete the record of author "James Taylor" then all the books he has written would also be deleted from the spreadsheet.

Ans 2) In 1NF, all row is expected to have only 1 tuple, but here in this spreadsheet the title field for Author "James Taylor" has 2 books, so it would be separated into single rows.

Ans 3) The table in the attached image below doesn't delete with Delete anomaly, i.e., for author "May Norton" if you delete this record, then the only book written by her would be deleted.

So, you have to convert this table into 2NF.

Make separate tables for Author and Book

Author(Author Name, Author Country)

Books(Author Name, Book title, Publisher, Publisher Location, Year, price)

This cannot be normalized any further.

3 0
1 year ago
The groups_per_user function receives a dictionary, which contains group names with the list of users. Users can belong to multi
Akimi4 [234]

The groups_per_user function receives a dictionary, which contains group names with the list of users.

Explanation:

The blanks to return a dictionary with the users as keys and a list of their groups as values is shown below :

def groups_per_user(group_dictionary):

   user_groups = {}

   # Go through group_dictionary

   for group,users in group_dictionary.items():

       # Now go through the users in the group

       for user in users:

       # Now add the group to the the list of

         # groups for this user, creating the entry

         # in the dictionary if necessary

         user_groups[user] = user_groups.get(user,[]) + [group]

   return(user_groups)

print(groups_per_user({"local": ["admin", "userA"],

       "public":  ["admin", "userB"],

       "administrator": ["admin"] }))

3 0
2 years ago
Other questions:
  • Which of the following is ideal for long distance communication ?
    5·1 answer
  • A(n) _____ can be used to reveal a competitor’s program code, which can then be used to develop a new program that either duplic
    9·1 answer
  • Write a program in c or c++ to perform different arithmeticoperation using switch statement .the program will take two inputinte
    10·1 answer
  • Write a do-while loop that asks the user to enter two numbers. The numbers should be added and the sum displayed. The user shoul
    13·1 answer
  • 9.10: Reverse ArrayWrite a function that accepts an int array and the array ’s size as arguments . The function should create a
    9·1 answer
  • Delete Prussia from country_capital. Sample output with input: 'Spain:Madrid,Togo:Lome,Prussia: Konigsberg' Prussia deleted? Yes
    13·1 answer
  • You have configured your firewall to authenticate a group of 100 users who are in your company. You set up the database of users
    14·1 answer
  • Write the definition of a function named averager that receives a double parameter and return-- as a double -- the average value
    12·1 answer
  • You need to design a data storage scheme for Hayseed Heaven library data system. There are several hundred thousand large data r
    8·1 answer
  • Are bpos safe for organisations ? State your views on it
    8·1 answer
Add answer
Login
Not registered? Fast signup
Signup
Login Signup
Ask question!