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, 21.06.2019 22:00
Some of your friends have gotten into the burgeoning field of time-series data mining, in which one looks for patterns in sequences of events that occur over time. purchases at stock exchanges"what's being bought" are one source of data with a natural ordering in time. given a long sequence s of such events, your friends want an efficient way to detect certain "patterns" in them"for example, they may want to know if the four events buy yahoo, buy ebay, buy yahoo, buy oracle occur in this sequence s, in order but not necessarily consecutively. they begin with a collection of possible events (e.g., the possible transactions) and a sequence s of n of these events. a given event may occur multiple times in s (e.g., yahoo stock may be bought many times in a single sequence s). we will say that a sequence s is a subsequence of s if there is a way to delete certain of the events from s so that the remaining events, in order, are equal to the sequence s . so, for example, the sequence of four events above is a subsequence of the sequence buy amazon, buy yahoo, buy ebay, buy yahoo, buy yahoo, buy oracle their goal is to be able to dream up short sequences and quickly detect whether they are subsequences of s. so this is the problem they pose to you: give an algorithm that takes two sequences of events"s of length m and s of length n, each possibly containing an event more than once"and decides in time o(m + n) whether s is a subsequence of s.
Answers: 3
question
Computers and Technology, 22.06.2019 16:20
Octothorpe is another name for what common computer keyboard symbol?
Answers: 1
question
Computers and Technology, 23.06.2019 02:30
Three out of five seniors remain undecided about a college major at the end of their senior year.
Answers: 3
question
Computers and Technology, 23.06.2019 09:30
Facial expressions and gestures are examples of messages.
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
Health, 16.11.2020 21:30
question
Mathematics, 16.11.2020 21:30
question
History, 16.11.2020 21:30
Questions on the website: 13722361