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
Type the correct answer in the box. Spell all words correctly. Complete the sentence based on the role education plays to help y
CaHeK987 [17]

Answer:

what do i do??

Explanation:

8 0
3 years ago
Which group allows you to add notes to your presentation?Ella has finished drafting her presentation. What should she do next?
liq [111]
Ella should view the presentation as a slideshow to see how it will look to her audience. 
6 0
4 years ago
Read 2 more answers
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22
postnew [5]

Answer: 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40

Explanation: x1

8 0
3 years ago
A security administrator wants to empty the DNS cache after a suspected attack that may have corrupted the DNS server. The serve
sattari [20]

Answer:

IPCONFIG Pls mark brainliest

Explanation:

3 0
3 years ago
Which line in the following program will cause a compiler error?
kumpel [21]

Answer:

Line number 7.

Explanation:

If I am not wrong, the first line in this question would be #include<iostream>. That is used to add input and output stream of the program.

if we look at the line 1,2,3. These are just the packages/definition required to start a program.

Line 4 starts the main program and line 5 starts the block of main program. The block ends at line 10. So ,there should be no error in line 4,5 and 10.

If we look at line 6, we can see a constant integer(const int MY_VAL = 77) definition and initialization.

The main problem is, you cannot assign a value to a constant (MY_VAL) except during initializing stage.

Therefore, the line 6 is also true. However, this program is further trying to assign a value to constant at line 7. Therefore, the compiler will throw error (ERROR; assigning to const value).

4 0
3 years ago
Other questions:
  • Which of the following is a type of monitor port?
    10·1 answer
  • What type of device can be used to block unwanted traffic initiated from the internet and can also restrict internet access from
    6·1 answer
  • How do you do these two questions? The first might have multiple answers and the second will have only one answer.
    14·1 answer
  • Write a program using Python that prompts for an integer and prints the integer, but if something other than an integer is input
    11·2 answers
  • You wouldn't think a simple shop like Dippy Donuts would be an interesting target for hackers. But look beyond the donuts and yo
    7·1 answer
  • Adam is an Engineering student but has decided that he does not want to work in that field, but in the Manufacturing career clus
    11·2 answers
  • What did Bakers wear (1) in the Portugal does (2) when was author was young ???
    10·1 answer
  • What is the output of the following code:
    10·1 answer
  • 1.What is the output of the following program? [10 Marks]namespace ConsoleApp1{class Program{static void Main(string[] args){int
    13·1 answer
  • Types in java are divided into two categories. the primitive types are boolean, byte, char, short, int, long, float and double.
    5·1 answer
Add answer
Login
Not registered? Fast signup
Signup
Login Signup
Ask question!