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, 22.06.2019 01:00
Duplicating objects creates copies that a. move differently than the original object b. erase the original object c. look and act like the original object d. add events to a game
Answers: 1
question
Computers and Technology, 23.06.2019 14:30
Norder to receive financial aid at his vocational school, mario must fill out the fafsa. the fafsa is a form that must be completed to determine . in order to complete a fafsa, you must submit . the fafsa can students obtain
Answers: 2
question
Computers and Technology, 23.06.2019 14:30
Which of the following would not be considered a pc? a. mainframe b. desktop c. tablet pc d. laptop
Answers: 2
question
Computers and Technology, 23.06.2019 19:30
Anul 2017 tocmai s-a încheiat, suntem trişti deoarece era număr prim, însă avem şi o veste bună, anul 2018 este produs de două numere prime, 2 şi 1009. dorel, un adevărat colecţionar de numere prime, şi-a pus întrebarea: “câte numere dintr-un interval [a,b] se pot scrie ca produs de două numere prime? “.
Answers: 3
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
Mathematics, 18.06.2021 17:40
question
English, 18.06.2021 17:40
question
Social Studies, 18.06.2021 17:40