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
Daniel makes changes to a workbook named “Results.” He saves the file as “New Results” but did not realize that a worksheet name
elena55 [62]
All he would need to do is go into the sheet and change the name again. This will change the HTML so the computer will not be confused. The name should make sense, but he completely different from the original name :)
7 0
3 years ago
Swapping two numbers
Tju [1.3M]

Answer:

Swapping two numbers means exchange the values of two variables with each other.

8 0
3 years ago
Before you insert a page break, what should you do? select the font you want to use for the text that comes after the page break
Triss [41]
Put the insertion point where you want the page to break is what I would write.
7 0
3 years ago
You are called to assist in troubleshooting a network problem that has occurred soon after a significant IPv6 implementation. So
HACTEHA [7]

Answer:i dont kowe

Explanation:

5 0
3 years ago
What will be the results from running the following code?
kari74 [83]

Answer:syntax error

Explanation:

Correct on edg 2021

4 0
2 years ago
Other questions:
  • HURRY UP NEED HELP!!! What are examples of curricular education? Check all that apply.
    9·2 answers
  • The smallest building block of a wireless lan is a ______.
    5·1 answer
  • A film camera with only one lens is known as a(n)?
    11·1 answer
  • __________ is a very simple form of lossless data compression in which runs of data (that is, sequences in which the same data v
    6·1 answer
  • Which of the following scenarios describes an IT professional using the Internet and computer system access in an unprofessional
    7·1 answer
  • Describe your WGU program, including two specific requirements that this degree has for completion.
    14·1 answer
  • What do you do when ur grounded from all electronics and can't go outside and have t clean all day
    10·1 answer
  • We love silky. she is very honest join this by using conjunction ​
    11·2 answers
  • GIVING BRAINLIEST
    15·1 answer
  • _____is used to organize and modify the properties of the current selection.
    6·1 answer
Add answer
Login
Not registered? Fast signup
Signup
Login Signup
Ask question!