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
In the context of the data administration component of a database management system (DBMS), the acronym CRUD stands for _____. G
sdas [7]

Answer:

C.R.U.D stands for Create, Read, Update, Delete.

Explanation:

6 0
2 years ago
4. What is the package name in which the Scanner class resides?
Ahat [919]
Related Articles. Scanner is a class in java. util package used for obtaining the input of the primitive types like int, double, etc. and strings.
7 0
2 years ago
Database users who access data only through application programs are called
Alex777 [14]
A. casual users hope this helps
7 0
3 years ago
What is an Agile perspective on errors and mistakes in project development?
Minchanka [31]

Answer:

Mistakes can be caught early by working in short spurts that allow for immediate review, learning and adjustment. :)

3 0
2 years ago
Paul has been working long hours. He is tired and distracted by family issues, so he has not been doing record updates regularly
mina [271]

Answer:

Accidental data loss

Explanation:

Accidental data loss -

It refers to the removal or loss of certain data or information from the computer , due to some accident , is referred to as accidental data loss .

The loss of data can be due to some malicious intruders , or can be due to the fault of the user .

The information can be lost due to sudden power cut , natural calamities like fires , flood earthquake etc. , problem in hard disk etc.

Hence , from the given scenario of the question ,

The correct option is accidental data loss.

4 0
3 years ago
Other questions:
  • You just read a restaurant review on the internet of the newest restaurant in town. The writer of the article said the food was
    15·1 answer
  • In a transaction-processing system (TPS), if the TPS database can be queried and updated while the transaction is taking place,
    12·1 answer
  • __________ refers to rules, statutes, codes, and regulations established to provide a legal framework within which business may
    13·1 answer
  • In cell D5, enter a formula to calculate the number of days for the first workshop. Add 1 to the results to include the total nu
    11·1 answer
  • An adiabatic capillary tube is used in some refrigeration systems to drop the pressure of the refrigerant from the condenser lev
    15·1 answer
  • How does the teacher know you have completed your assignment in Google Classroom?
    12·1 answer
  • You have a small network at home that is connected to the internet. On your home network, you have a server with the IP address
    11·1 answer
  • When an expression containing a ____ is part of an if statement, the assignment is illegal.
    14·2 answers
  • What impact download speeds on different computers
    13·1 answer
  • How many pages is 1500 words double spaced 12 font?.
    10·1 answer
Add answer
Login
Not registered? Fast signup
Signup
Login Signup
Ask question!