![Computers and Technology](/tpl/images/cats/informatica.png)
Computers and Technology, 27.04.2021 03:40, harri26348
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();
}
}
![answer](/tpl/images/cats/otvet.png)
Answers: 3
Other questions on the subject: Computers and Technology
![image](/tpl/images/cats/informatica.png)
Computers and Technology, 22.06.2019 22:50, youngboymark123
Assume the existence of a bankaccount class. define a derived class, savingsaccount that contains two instance variables: the first a double, named interestrate, and the second an integer named interesttype. the value of the interesttype variable can be 1 for simple interest and 2 for compound interest. there is also a constructor that accepts two parameters: a double that is used to initialize the interestrate variable, and a string that you may assume will contain either "simple", or "compound", and which should be used to initialize the interesttype variable appropriately. there should also be a pair of functions getinterestrate and getinteresttype that return the values of the corresponding data members (as double and int respectively).
Answers: 2
![image](/tpl/images/cats/informatica.png)
![image](/tpl/images/cats/informatica.png)
![image](/tpl/images/cats/informatica.png)
Computers and Technology, 23.06.2019 21:30, maddietomlinson113
Examine the list below. which factors positively affect lifetime income? check all that apply.
Answers: 1
Do you know the correct answer?
6.22 LAB: Output values below an amount - methods
Write a program that first gets a list of intege...
Questions in other subjects:
![Konu](/tpl/images/cats/istoriya.png)
History, 06.11.2019 03:31
![Konu](/tpl/images/cats/ekonomika.png)
![Konu](/tpl/images/cats/biologiya.png)
Biology, 06.11.2019 03:31
![Konu](/tpl/images/cats/fizika.png)
Physics, 06.11.2019 03:31
![Konu](/tpl/images/cats/biologiya.png)
Biology, 06.11.2019 03:31
![Konu](/tpl/images/cats/istoriya.png)
![Konu](/tpl/images/cats/health.png)
Health, 06.11.2019 03:31
![Konu](/tpl/images/cats/en.png)
English, 06.11.2019 03:31
![Konu](/tpl/images/cats/fizika.png)
Physics, 06.11.2019 03:31
![Konu](/tpl/images/cats/himiya.png)
Chemistry, 06.11.2019 03:31