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
This tag element is the last one used in the html code sequence
satela [25.4K]

Answer:

Looking closely at the HTML code sequence, it does seem that the tag element is the endpoint from where the HTML form gets the input, like input boxes, checkboxes, radio buttons, etc. And hence it is correct to say that the tag elements are the last one used in the HTML code sequence. And in the HTML code sequence head title script and styles comes at the top, and hence we mention the script or the Javascript code basically at the last, such that the HTML code or the web page run one time at least.

Explanation:

Please check the answer section.

3 0
3 years ago
If all humans started from one tiny cell why do you think we all look and act differently
scZoUnD [109]
The one cell evolved into different categories by adapting to its human/animal/plant’s habitat
3 0
3 years ago
Johnny is a member of the hacking group Orpheus1. He is currently working on breaking into the Department of Defense's front end
sweet [91]

Answer:

RainbowTables

Explanation:

RainbowTables is the best option when the cracker has limited time.

6 0
3 years ago
Create a simple program of your own using a Loop that counts and displays numbers 1-10.
avanturin [10]

Answer:

I think

Explanation:

you....

8 0
3 years ago
Which formula is used to measure accuracy?
Westkost [7]

Answer:You can only find REaccuracy if you know the actual “true” measurement… something that's difficult to do unless you're measuring against the atomic clock. The formula is: REaccuracy = (Absolute error / “True” value) * 100%.

Explanation:

7 0
2 years ago
Other questions:
  • Your boss in the human resources department asks you to write a function that calculates the length of time that employees have
    6·1 answer
  • What is safe mode?
    9·1 answer
  • Typically, a programmer develops a programâs logic, writes the code, and ____ the program, receiving a list of syntax errors.
    6·1 answer
  • List and describe three options in the autocad object snap toolbar
    8·1 answer
  • Laura is confused with the spelling of the word pronunciation. She types the word pronunciation. Which feature of the auto corre
    8·2 answers
  • Which key must you press after you write into a cell?
    12·1 answer
  • You and your friend who lives far away want to fairly and randomly select which of the two of you will travel to the other’s hom
    6·1 answer
  • What is the interface of an app?
    11·1 answer
  • Algorithm to eat orange<br><br>​
    10·2 answers
  • 7.2.4 Area of Triangle HELP PLEASE!! (JAVA SCRIPT) I WILL WAIT FOR THE SOLUTION.
    12·1 answer
Add answer
Login
Not registered? Fast signup
Signup
Login Signup
Ask question!