estion 12+13 (2 parts) te a complete program that contains and uses a function f
ID: 3723799 • Letter: E
Question
estion 12+13 (2 parts) te a complete program that contains and uses a function findiowScors to find the number of.low inside an array of integers. Question 12 (function prototype/definition-20 points) Write a function findLowscores that searches an array of integers for the number of "low" scores. A "low score is a score less than a given threshold. The function takes three arguments: I. scoresList, an array of integers to be searched 2. size, the number of elements in the array 3. threshold, an integer The function returns the total number of scores less than threshold in the array. Question 13 (Rest of the program - 20 points) The program creates and populates an integer array of 5 exam scores with entries from the user. After calculating the total number of scores in the array that are "low", i.e. less than 50, the program prints to screen whether the performance was AboveAverage or OnOrBelowAverage. Performance is OnOrBelowAverage if more than half of the class has "low" scores and OnOrBelowAverage, otherw For example, if the array contains 92, 89, 65, 84, 35, the program should print: AboveAverage Performancee OLUTIONExplanation / Answer
Hi... I have written java program for the above. Please check below.
AvgScores.java
import java.util.Scanner;
public class AvgScores {
public static void main(String[] args) {
// TODO Auto-generated method stub
Scanner sc = new Scanner(System.in);
int n=0;
System.out.println("Enter array length:");
n = sc.nextInt();
int arr[] = new int[n];
System.out.println("Enter array values:");
for(int i=0;i<n;i++){
arr[i] = sc.nextInt();
}
int count = findLowScores(arr,n,50);
int half = n/2;
if(count>=half){
System.out.println("Above Average performance");
}else{
System.out.println("On or Below Average performance");
}
}
private static int findLowScores(int[] arr,int len,int threshold) {
// TODO Auto-generated method stub
int count=0;
for(int i=0;i<len;i++){
if(arr[i]>threshold){
count++;
}
}
return count;
}
}
Output:
Enter array length:
5
Enter array values:
92
89
65
84
35
Above Average performance
Please test the code and let me know any issues. Thank you. All the best.
Related Questions
Navigate
Integrity-first tutoring: explanations and feedback only — we do not complete graded work. Learn more.