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
Blizzard [7]
3 years ago
8

Double any element's value that is less than controlValue. Ex: If controlValue = 10, then dataPoints = {2, 12, 9, 20} becomes {4

, 12, 18, 20}.
import java.util.Scanner; public class StudentScores { public static void main (String [] args) { Scanner scnr = new Scanner(System.in); final int NUM_POINTS = 4; int[] dataPoints = new int[NUM_POINTS]; int controlValue; int i; controlValue = scnr.nextInt(); for (i = 0; i < dataPoints.length; ++i) { dataPoints[i] = scnr.nextInt(); } for (i = 0; i < dataPoints.length; ++i) { System.out.print(dataPoints[i] + " "); } System.out.println(); } }
Computers and Technology
2 answers:
Aleksandr [31]3 years ago
5 0

Answer:

import java.util.Scanner;

public class StudentScores

{

public static void main(String[] args) {

 Scanner scnr = new Scanner(System.in);

 final int NUM_POINTS = 4;

 int[] dataPoints = new int[NUM_POINTS];

 int controlValue;

 int i;

 controlValue = scnr.nextInt();

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

     dataPoints[i] = scnr.nextInt();

 }

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

     System.out.print(dataPoints[i] + " ");

 }

 System.out.println();

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

     if(dataPoints[i] < controlValue){

         dataPoints[i] = dataPoints[i] * 2;          

     }

     System.out.print(dataPoints[i] + " ");

 }

}

}

Explanation:

*Added parts highligted.

After getting the control value and values for the array, you printed them.

Create a for loop that iterates through the dataPoints. Inside the loop, check if a value in dataPoints is smaller than the contorolValue. If it is, multiply that value with 2 and assign it to the dataPoints array. Print the elements of the dataPoints

zhannawk [14.2K]3 years ago
5 0

Answer:

import java.util.Scanner;

public class numm3 {

   public static void main (String [] args) {

       Scanner scnr = new Scanner(System.in);

       final int NUM_POINTS = 4;

       int[] dataPoints = new int[NUM_POINTS];

       int controlValue;

       int i;

       System.out.println("Enter the control Variable");

       controlValue = scnr.nextInt();

       System.out.println("enter elements for the array");

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

           dataPoints[i] = scnr.nextInt();

       }

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

           System.out.print(dataPoints[i] + " ");

       }

       System.out.println();

       //Doubling elements Less than Control Variable

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

           if (dataPoints[i]<controlValue){

               dataPoints[i] = dataPoints[i]*2;

           }

           System.out.print(dataPoints[i] + " ");

       }

       System.out.println(); } }

Explanation:

See the additional code to accomplish the task in bold

The trick is using an if statement inside of a for loop that checks the condition (dataPoints[i]<controlValue) If true, it multiplies the element by 2

You might be interested in
One thing we might want to know, given an input to a chatbot, is if the input is a question.
3241004551 [841]

Answer:

Following are the code to this question:

def is_question(input_string): # defining method is_question  

   output = '?' in input_string # checking question mark symbol in value

   return output #return value

input_string = input('Enter any string value: ') # defining variable input_string to input value

print (is_question(input_string)) # call method and print return value

Output:

Enter any string value: what is your name?

True

Explanation:

In the given python program code, a method "is_question" is declared, which accepts an "input_string" value in its parameter.

  • Inside the method, an output variable is used, that search question symbol in the parameter value and return its value.
  • In the next step, the input_string variable is declared, which uses the input method to accepts string value and passes into method calling time and print its return value.
5 0
3 years ago
Which is true about routers and switches?
Pepsi [2]

Answer:

Routers control traffic between networks while switches control traffic within a network

Explanation:

Router and switches both are used to control the traffic. In local area network, different computer are connected with each other with in the organization or network. Switch is used to connect all the computers or devices in the local area network (LAN). The switch is responsible for connecting all the computers in the LAN and controlling the traffic within the LAN network.

On the other hand, Wide Area Network (WAN) is consist of multiple number of  Local Area Networks (LANs). To connect all the LAN router is used. Router is responsible for connecting all the networks in the WAN and also responsible for controlling traffic between different networks.

5 0
3 years ago
If one employee is assigned to a project and each project has only one employee working on it, there is a(n) ____ relationship b
Len [333]

Answer:

One-to-one is the answer because there is one project and one employee working on one project.

5 0
3 years ago
Match these items. 1 . Naturalization Act stated that a foreigner had to live in the United States fourteen years to become a ci
Romashka-Z-Leto [24]

Answer and Explanation:

1. Naturalization Act:

  • Expressed that an outsider needed to live in the United States fourteen years to turn into a native.

2. Judiciary Act:

  • It was an effort to save Federalist standards

3. Sedition Act:

  • Approved fines up to $5,000 and detainment for ruining the legislature.

4. Alien Act:

  • Allowed the President to oust aliens or outsiders whom he judged "risky"

5. Alien and Sedition Acts:

  • Constrained through Congress by the Federalists.

6. Alien Enemies Act:

  • Allowed the President to detain or extradite hazardous outsiders or aliens in time of war
8 0
3 years ago
Predict the future that social media will have on society or the environment
hichkok12 [17]

Answer:

The future that this world holds for Social media may as well be known as the end of self opinions. This is because now  a days many people seek the opinions of others and no longer take there opinions into count. Social media can also damage the environment. This is because since people are on there phone longer bc of social media they also need to charge there phone more, which needs electricity, which comes from the burning of fossil fuels .

5 0
3 years ago
Other questions:
  • What is cryptocurrency ? I need to do a research one it please help!
    6·1 answer
  • geoffrey is on location for a long shoot. he is worried that the battery power in his camera will not last. which source can he
    5·1 answer
  • Can some one help me on 4&amp;5
    6·1 answer
  • Refer to the following statement: “We have implemented several IT solutions:
    14·1 answer
  • When was the federal commission act put into effect?????
    13·1 answer
  • Which of these examples demonstrate portfolio income?
    13·2 answers
  • The price of an item you want to buy is given in dollars and cents. You pay for it in cash by giving the clerk d dollars and c c
    6·1 answer
  • Activity 8. Direction: Read the article and make an outline. Be guided by the rubric for outlining. Write your answer on a separ
    15·1 answer
  • What is the recipe for enchanting table?
    14·2 answers
  • the implications your organization of providing email facilities to individuals in the workplace in terms of security and virus
    10·1 answer
Add answer
Login
Not registered? Fast signup
Signup
Login Signup
Ask question!