subject

6.22 LAB: Output values below an amount - methods Write a program that first gets a list of integers from input. The input begins with an integer indicating the number of integers that follow. Then, get the last value from the input, and output all integers less than or equal to that value. Assume that the list will always contain less than 20 integers.

Ex: If the input is:

5 50 60 140 200 75 100
the output is:

50 60 75
The 5 indicates that there are five integers in the list, namely 50, 60, 140, 200, and 75. The 100 indicates that the program should output all integers less than or equal to 100, so the program outputs 50, 60, and 75. For coding simplicity, follow every output value by a space, including the last one.

Such functionality is common on sites like Amazon, where a user can filter results.

Write your code to define and use two methods:
public static void getUserValues(int[] myArr, int arrSize, Scanner scnr)
public static void outputIntsLessThanOrEqualToThreshol d(int[] userValues, int userValsSize, int upperThreshold)

Utilizing methods will help to make main() very clean and intuitive.

My Code & Error Message Attached
import java. util. Scanner;

public class LabProgram {

public static void GetUserValues(int[] myArr, int arrSize, Scanner scnr){
int i;
for(i=0;i myArr[i] = scnr. nextInt();
}
}

public static void outputIntsLessThanOrEqualToThreshol d(int[] userValues, int userValsSize, int upperThreshold) {
int i;
for(i=0;i if(userValues[i] <= upperThreshold)
System. out. print(userValues[i]+" ");
}

}

public static void main(String[] args) {
Scanner scnr = new Scanner(System. in);
int[] userValues = new int[20];
int upperThreshold;
int numVals;

numVals = scnr. nextInt();
GetUserValues(userValues, numVals, scnr);

upperThreshold = scnr. nextInt();
outputIntsLessThanOrEqualToThreshol d(userValues, numVals, upperThreshold);
System. out. println();

}
}


6.22 LAB: Output values below an amount - methods

Write a program that first gets a list of integ

ansver
Answers: 3

Another question on Computers and Technology

question
Computers and Technology, 24.06.2019 02:30
Write the pseudo code for this problem based on what you learned from the video. the purpose is to design a modular program that asks the user to enter a distance in kilometers, and then converts that distance to miles. the conversion formula is as follows: miles = kilometers x 0.6214
Answers: 3
question
Computers and Technology, 24.06.2019 13:30
Type the correct answer in the box. spell all words correctly. what is the default margin width on all four sides of a document? by default, the document has a margin on all four sides.
Answers: 1
question
Computers and Technology, 24.06.2019 17:40
When analyzing data sets, such as data for human heights or for human weights, a common step is to adjust the data. this can be done by normalizing to values between 0 and 1, or throwing away outliers. for this program, adjust the values by subtracting the smallest value from all the values. the input begins with an integer indicating the number of integers that follow. ex: if the input is 5 30 50 10 70 65, the output is: 20 40 0 60 55
Answers: 1
question
Computers and Technology, 24.06.2019 19:00
Luis is cloud-based( microsoft bot framework). true false
Answers: 1
You know the right answer?
6.22 LAB: Output values below an amount - methods Write a program that first gets a list of intege...
Questions
question
Spanish, 15.12.2020 02:40
question
SAT, 15.12.2020 02:40
Questions on the website: 13722360