Answer:
- import java.util.Scanner;
-
- public class Main {
- public static void main (String [] args) {
-
- int jersey_num [] = new int[5];
- int rating [] = new int[5];
-
- Scanner inStream = new Scanner(System.in);
-
- for(int i=0; i < 5; i++){
- System.out.print("Enter player " + (i+1) + "'s jersey number:");
- jersey_num[i] = inStream.nextInt();
-
- System.out.print("Enter player " + (i+1) + "'s rating:");
- rating[i] = inStream.nextInt();
- }
-
- System.out.println("ROSTER");
-
- for(int j=0; j < 5; j++){
- System.out.println("Player " + (j+1) + "-- Jersey number: " + jersey_num[j] + ", Rating: " + rating[j]);
- }
- }
- }
Explanation:
The solution code is written in Java. Firstly create two array, jersey_num and rating, with int type. This is to hold the five pairs of numbers input by user (Line 6 -7).
Next, create a for loop that run for 5 iterations and in each iteration prompt user to input jersey number and rating (Line 11 -17). The input number and rating will be set to the array, jersey_num and rating, respectively.
Next, print the title "Roster" (Line 19).
Create another for loop to display the five input pair of values (Line 21 - 23).
I can not give you the direct answer but I can give you some ideas. The videos that go viral have an effect that makes peoples ideas clear and shows what people are into and then more people can get to know about these things.
Answer and Explanation:
Using Javascript:
function mean(nums){
var array_numbers= new array(nums);
var meanofNums= array_numbers.reduce()/array_numbers.length;
Console.log(meanofNums);
}
Function Std(nums){
var OurArray= new Array(nums);
var meanOfnums= mean(nums);
var i;
for(i=0; i<=OurArray.length; i++){
OurArray[i]= OurArray[i]-meanOfnums*OurArray[i]-meanOfnums;
}
var al_stdOfnums= OurArray.reduce()/OurArray.length;
var stdOfnums= Math. sqrt(al_stdOfnums);
Console.log(stdOfnums);
}
function meanStdDev (nums){
mean(nums);
Std(nums);
}
/*From the code above, we have defined functions and used them in the last function definition meanStdDev (nums), making for code reusability. In defining the functions, we have followed the formulas for calculating mean and standard deviations and implemented in that order. Notice how we used a for loop in std(nums) function definition to iterate through the elements of the array nums, squaring each value and reassigning a new value for each element(using index value) in the array. We then added these values in array using reduce method, dividing by array length and square rooting the value using the math object method sqrt().*/