CMIS 141 Quiz 3 Latest Questions with Answers in red. This Quiz Received 100%
Answers in red. This quiz received 100% Question 1 (10 points) Write a method that computes the average of the values in an array of doubles. The header of the method is as follows: public static double average(double[] x) public static double average(double [] x) { double sum=0; for( int i=0 ;i<h ;i++) { sum+=x[i]; } return (sum/h); } Question 2 (20 points) Write a complete Java class that will create a 2D array of randomly generated ints with dimensions of 5 rows and 10 columns. Print the values of each cell to a 5x10 table. (Note: a complete Java class means the code should compile and run without issue. Be sure the output displays a set of random ints formatted in 5 rows by 10 columns. // Graded Quiz 3 // Developer: // Course: CMIS141, Section 7981 // Professor: R. Rowson import .Random; public class Array2D { int aR1[ ][ ]; public Array2D() { Random r=new Random(); aR1 = new int[5][10]; for(int i=0;i<5;i++) { for(int j=0;j<10;j++) { aR1[i][j]=(int)Int(50); //Random Numbers from 0 to 49 inclusive } } } public void display() { for(int i=0;i<5;i++) { for(int j=0;j<10;j++) { S(aR1[i][j]+"t"); } Sln(""); } } public static void main(String[] args) { Sln("n2D Array Output"); Array2D gew=new Array2D(); ay();
Geschreven voor
- Instelling
- University Of Maryland - University College
- Vak
- CMIS 141
Documentinformatie
- Geüpload op
- 2 september 2021
- Aantal pagina's
- 2
- Geschreven in
- 2021/2022
- Type
- Tentamen (uitwerkingen)
- Bevat
- Vragen en antwoorden
Onderwerpen
-
cmis 141
-
cmis 141 quiz 3