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
A city planner is using simulation software to study crowd flow out of a large arena after an event has ended. The arena is loca
Damm [24]

Answer:

d)

Explanation:

The main limitation of simulations is that running a simulation requires a large number of observations to be collected before it can be used to explore a problem. In a real life situation there are thousands of variables to take into consideration which can drastically affect the way that the situation unfolds at any given time. Therefore, in order to replicate/simulate such a scenario all of these variables need to be taken into consideration. This data can take a large amount of time to observe and collect in order to implement into the simulation so that it provides an accurate depiction of the problem.

6 0
3 years ago
What are the basic problem that my pc can have?
Lena [83]
A virus, malware, unplugged, used too much storage, etc.
5 0
4 years ago
Which is the base class in the following statement? class car : public vehicle
tatiyna

The base class in the following statements is the vehicle class.

<h3>What is a base class?</h3>

A base class is also known as a parent class.

A parent class is the existing class from which the other classes are determined and properties are inherited.

The class car is the child class. The child class inherit the properties of the parent class or the base class.

Therefore, the base class is the vehicle class.

learn more on class here; brainly.com/question/14293976

#SPJ11

8 0
2 years ago
*PLEASE ANSWER QUICK*
dezoksy [38]

Answer:

pretty sure its insert.

Explanation:

8 0
3 years ago
Read 2 more answers
Which of the following is a good design tip.
tia_tia [17]

Answer:

Offer as much extraneous information as possible. The viewer will decide what is important.

5 0
3 years ago
Other questions:
  • A Chief Information Officer (CIO) recently saw on the news that a significant security flaws exists with a specific version of a
    5·1 answer
  • Alison retrieved data from a company database containing personal information on customers. When she looks at the SSN field, she
    14·1 answer
  • Samantha was calculating a mathematical formula on an electronic spreadsheet. She used multiple values to recalculate the formul
    7·2 answers
  • Complete the function doubling_time that takes two parameters bal and apr and uses a while loop compute the number of years it t
    10·1 answer
  • Assume that the vector arr has been declared. In addition, assume that VECTOR_SIZE has been defined to be an integer that equals
    10·1 answer
  • When you open your word-processing program, it opens in a<br> field<br> menu
    9·2 answers
  • Hydraulic pressure is the same throughout the inside of a set of brake lines. What determines the amount of resulting mechanical
    7·1 answer
  • The following Mic1 microcode excerpt shows support for a possible 7 bit opcode, 8 bit integer argument machine instruction (orga
    14·1 answer
  • V. ASSESSMENT (Time Frame:
    7·1 answer
  • What are the chances of a baby zombie to spawn in full golden armor in MC? ​
    15·2 answers
Add answer
Login
Not registered? Fast signup
Signup
Login Signup
Ask question!